Skip to main content
13-Aquamarine
May 25, 2022
Solved

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

  • May 25, 2022
  • 1 reply
  • 1115 views

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?

Best answer by RFS

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

1 reply

HelesicPetr
22-Sapphire II
May 27, 2022

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;
}

 

RFS13-AquamarineAuthorAnswer
13-Aquamarine
May 30, 2022

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