Skip to main content
16-Pearl
February 24, 2015
Question

Finding Change Notice thru workflow

  • February 24, 2015
  • 1 reply
  • 734 views

Looking for code that I can add to a workflow that will search for CNs that are not at resolved state in the system with the same attribute value as a WTdoc.



Anyone have code they can share? I have reached out to PTC, but they have yet to supply anything relevant and they are starting to push back saying they don't supply complete code....surprising that that is the answer to customers when it comes to something small and simple like this.



Thanks,


Greg


1 reply

12-Amethyst
February 25, 2015

My initial thought would be to create a query spec that searches for all CNs that are not at resolved state - if there are any other states you could filter out it would make the next part much faster. Code for that would look something like this:



QuerySpec spec = new QuerySpec(ChangeOrder2.class);


spec.appendWhere(new SearchCondition(ChangeOrder2.class, "state.state", SearchCondition.NOT_EQUAL, "RESOLVED", false), new int[]{});


QueryResult results = PersistenceHelper.manager.find((StatementSpec)spec);



Once you have the list, you would have to iterate over all of them (keep in mind this could take some time if you have many CNs that are not resolved) and retrieve the SON attributeto compare to your WTDocument.


Getting the SON attribute from the CN would look something like this:


LWCNormalizedObject lwcObj = new LWCNormalizedObject(changeNoticeObject,null,Locale.ENGLISH,null);
lwcObj.load("salesOrderNumber");
String cnSON = (String)lwcObj.get("salesOrderNumber");


You would do something similar to get the attributefor the WTDoc and compare the values.