cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Need to get the Change objects have a particular document/part/etc. as part of the change.

RFS
11-Garnet
11-Garnet

Need to get the Change objects have a particular document/part/etc. as part of the change.

As part of validating a Change Notice before approval, we want to make sure the Resulting objects have not already been part of another change.  We can check states on the docs for most cases, but sometimes we need to take the resulting documents and look at any other CNs that are also trying to validate.  I already have the code that takes a CN and returns the list of Resulting documents, parts, etc.  What code takes a document and returns the list of CNs containing it?

1 ACCEPTED SOLUTION

Accepted Solutions
RFS
11-Garnet
11-Garnet
(To:HelesicPetr)

Thank you.  I will try this code out and post success or failure.

View solution in original post

2 REPLIES 2
HelesicPetr
21-Topaz II
(To:RFS)

Hi @RFS 

Following code returns ArrayList of ChangeNotice where object is in resulting table.

 

Use null for an input filter 

Persistable input is any object from Windchill that can be part of change process.

 

public static ArrayList<WTChangeOrder2> getChangeOrderResultingFromObject(Persistable persistable, filterUtilChanges filter)
{
ArrayList<WTChangeOrder2> retValue = new ArrayList<WTChangeOrder2>();
if (persistable == null)
{
return retValue;
}
try
{
QueryResult queryresult = PersistenceServerHelper.manager.expand(persistable, "ALL", ChangeRecord2.class, false);
if (queryresult != null && queryresult.size() > 0)
{
while (queryresult.hasMoreElements())
{
ChangeRecord2 changeRecord = (ChangeRecord2) queryresult.nextElement();
WTChangeActivity2 changeActivity = (WTChangeActivity2) changeRecord.getRoleAObject();
QueryResult latestChangeOrder = ChangeHelper2.service.getLatestChangeOrder(changeActivity);
if (latestChangeOrder != null && latestChangeOrder.size() > 0)
{
while (latestChangeOrder.hasMoreElements())
{
WTChangeOrder2 item = (WTChangeOrder2) latestChangeOrder.nextElement();
if ((filter == null) || (filter.isValidWTChangeOrder2(item)))
{
retValue.add(item);
}
}
}
}
}
} catch (WTException e)
{
e.printStackTrace();
}
return retValue;
}

 

RFS
11-Garnet
11-Garnet
(To:HelesicPetr)

Thank you.  I will try this code out and post success or failure.

Top Tags