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?
Solved! Go to Solution.
Thank you. I will try this code out and post success or failure.
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;
}
Thank you. I will try this code out and post success or failure.