Skip to main content
1-Visitor
May 13, 2015
Solved

How can I show the value of a global attribute on a Change Request on a Change notice?

  • May 13, 2015
  • 8 replies
  • 4083 views

I have a global attribute I created on a Change Request called KPC. I want to see the value of this attribute on a Change Notice. I also need to use the value of this attribute in a workflow for routing.

Best answer by JørnAHansen

‌Raymond,

The last line in the table of examples in CS131355 has this:

theChangeActivity2@wt.change2.IncludedIn2~theChangeOrder2^wt.change2.WTChangeOrder2~theChangeOrder2@wt.change2.AddressedBy2~theChangeRequest2^wt.change2.WTChangeRequest2~numberDisplay the Change Request number in an alias attribute on the Change Activity. This link navigates through the Change Notice to achieve the final result.

I haven't tried it out myself but agree that it from a maintenance perspective would be preferable over Java code.

Please share hare if you get it working or not.

8 replies

1-Visitor
May 13, 2015

If you need to show it, you need to create an equivalent attribute in the CN. If you only need the CR attribute value for CN routing, then you could access the CR from the CN Workflow and access the attribute. Either way you'll need LWCNormalizedObject up to WC10.1 and PersistableAdapter WC10.2- to read and then write the attribute value. Insert an Expression Robot in an appropriate spot in the CN workflow to do this.

rdrennen1-VisitorAuthor
1-Visitor
May 14, 2015

Keir,

Yes I need to show it. What type of attribute do you create to in the CN to show the value from the CR? I have been trying to create an alias attribute, but not sure on the mapping.

Thanks,

Ray

1-Visitor
May 15, 2015

‌Raymond,

The last line in the table of examples in CS131355 has this:

theChangeActivity2@wt.change2.IncludedIn2~theChangeOrder2^wt.change2.WTChangeOrder2~theChangeOrder2@wt.change2.AddressedBy2~theChangeRequest2^wt.change2.WTChangeRequest2~numberDisplay the Change Request number in an alias attribute on the Change Activity. This link navigates through the Change Notice to achieve the final result.

I haven't tried it out myself but agree that it from a maintenance perspective would be preferable over Java code.

Please share hare if you get it working or not.

16-Pearl
May 14, 2015

We use code in the workflow that pulls that value from the CR and adds to a CN when automatically created. I can supply if you would like.

Greg

16-Pearl
May 14, 2015

Using an workflow Expression Robot (expression tab):

try {

com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject((wt.fc.Persistable)primaryBusinessObject,null,null,null);

obj.load("Reason_For_Change");

Boolean flag=false;

if (obj.get("Reason_For_Change")==null || obj.get("Reason_For_Change").toString().equalsIgnoreCase("") ){

wt.fc.QueryResult fc= wt.change2.ChangeHelper2.service.getChangeRequest((wt.change2.ChangeOrderIfc)primaryBusinessObject);

while (fc.hasMoreElements()) {

wt.change2.WTChangeRequest2 object = (wt.change2.WTChangeRequest2) fc.nextElement();

com.ptc.core.lwc.server.LWCNormalizedObject objcr = new com.ptc.core.lwc.server.LWCNormalizedObject((wt.fc.Persistable)object,null,null,null);

objcr.load("Reason_For_Change");

Object ncr= objcr.get("Reason_For_Change");

if (ncr !=null && !ncr.toString().equalsIgnoreCase("")) {

obj.set("Reason_For_Change",ncr.toString());

obj.apply();

flag=true;

}

}

}

if(flag) {

primaryBusinessObject=(wt.change2.WTChangeOrder2) wt.fc.PersistenceHelper.manager.modify((wt.fc.Persistable)primaryBusinessObject);

}

} catch (wt.util.WTException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

We have multiples of the exp robots in a row as there is a limit to the number of code characters. Replace "Reason_For_Change" above with your attribute then test by creating a change notice and propagating.

rdrennen1-VisitorAuthor
1-Visitor
May 14, 2015

Greg,

I am pulling the attribute in the workflow ok. I was looking for a way to display the attribute value on the details tab of the CN as well.

Thanks,

Ray