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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

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

rdrennen
1-Visitor

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

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.

ACCEPTED SOLUTION

Accepted Solutions

‌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.

View solution in original post

8 REPLIES 8

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.

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

‌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.

Jorn,

I had to remove the section that passed the variable to the Change Activity,

Thanks,

Ray

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

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.

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

Hi Raymond,

I tend to use Global Attributes. Code in a Workflow Expression Robot as Greg Olson‌ has shown above.

To display in the Details Tab, you'll want to go to the Type and Attribute Manager and Edit your Change Notice Type. Select the Layouts Tab and an appropriate Layout(s) see screenshot. From there you can drag and drop an Attribute into an existing Attribute Group or create a new Attribute Group. Note - Sub-Type Layouts inherit from parents.

2015-05-17_19-23-41.jpg

BTW - Nice job on this PTC, Thanks! Having this type of capability to manipulate how information is presented to the User is really beneficial. Still room for improvement to streamline Administration.

Announcements


Top Tags