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

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

API to propagate from problem report to change request

dmcalister-2
14-Alexandrite

API to propagate from problem report to change request

I am using some code in the confirmed transition for the Analyze Problem Report workflow task to auto-create the change request. It works and even links the new change request to the problem report. But it does not propagate the info from the problem report. Does anyone know how to do it?

 

I tried setting the preference Change Information Propagation to Selected but it appears to only work in the UI. I want to do the same thing with the code that checking the box does in the UI.

2 REPLIES 2

 Looks like this is done using ChangeRequestAttributePopulator and is not available to call from an API. The best alternative is to use persistableadapter to copy over the attributes

Thanks for the comment.

I've had to break this down to attributes, affected objects and affected end items. If I can get those objects to propagate I'll be happy. For attributes, I'm using this technique: https://www.ptc.com/en/support/article?n=CS130730 .

 

For effected objects, this might not be the best way, but it seems to work:

 

//Propagate Affected Objects to CR
//per CS128877 and CS167405
wt.fc.QueryResult qr = wt.fc.PersistenceHelper.manager.navigate((wt.change2.ChangeIssue) primaryBusinessObject, wt.change2.ReportedAgainst.CHANGEABLE2_ROLE, wt.change2.ReportedAgainst.class, false);
for (int i = 0; i < qr.size(); i++) {
 wt.change2.ReportedAgainst ra = (wt.change2.ReportedAgainst) qr.nextElement();
 wt.change2.Changeable2 changeable = ra.getChangeable2();
 wt.fc.collections.WTSet links = new wt.fc.collections.WTHashSet();
 wt.change2.RelevantRequestData2 relevantRequestData = wt.change2.RelevantRequestData2.newRelevantRequestData2(changeable, CRNew2);
 relevantRequestData.setDescription(ra.getDescription());
 links.add(relevantRequestData);
 wt.change2.ChangeHelper2.service.storeAssociations(CRNew2, links);
}

 

I haven't figured out affected end items yet. I know I can get them from the problem report into a queryresult using:

wt.fc.QueryResult qrAffectedEndItems = wt.change2.ChangeHelper2.service.getSubjectProducts((wt.change2.ChangeIssue) primaryBusinessObject);

But, I don't know if that can be used to add them to the CR.

Announcements

Top Tags