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

Add a Custom Attribute to a specific task in Workflow

SOLVED
Highlighted
Participant

Add a Custom Attribute to a specific task in Workflow

Is there an easy way to add a custom attribute only to a specific task in a workflow? For example, in the OOTB Change Notice workflow there is an Audit task. How would I add an attribute to this task only?

-Ryan

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Add a Custom Attribute to a specific task in Workflow

ok then change the set statement to

obj.set("IFRQ_Number", IFRQ_Number);

13 REPLIES 13

Re: Add a Custom Attribute to a specific task in Workflow

You can create variable in Task:

1.jpg

Re: Add a Custom Attribute to a specific task in Workflow

Awesome. I actually got this far on my own. Next I want to take that variable information and map it back into an attribute on the change notice that way it is visible on the details of the change.

Any idea what the code for this is?

Re: Add a Custom Attribute to a specific task in Workflow

It ends on what version you're on... LWCNormalizedObject is the API to use for earlier versions, for 10.2 and beyond use PersistableAdapter. See the JavaDoc for your version for code samples

Re: Add a Custom Attribute to a specific task in Workflow

I'm on Windchill PDMLink 10.2 M020. I downloaded the "JavaDoc" but it is way over my head. Any Chance you could supply me with the code snippet I need to put in the expression robot? The internal name of the attribute I am working with is "IFRQ_Number" and the variable is named the same. I tried this code but there is an error when I do check syntax... not sure how to fix or if this is even the correct code:

wt.change2.WTChangeOrder2thisNotice = (wt.change2.WTChangeOrder2thisNotice) primaryBusinessObject;

com.ptc.core.lwc.server.LWCNormalizedObject obj = new com.ptc.core.lwc.server.LWCNormalizedObject(thisNotice,null,null,null);

obj.load("IFRQ_Number");

Object nameValue = obj.get("IFRQ_Number");

ChangeNoticeName = obj.get("IFRQ_Number")toString();

Re: Add a Custom Attribute to a specific task in Workflow

Hi,

Try below code.

wt.change2.WTChangeOrder2 thisNotice = (wt.change2.WTChangeOrder2) primaryBusinessObject;

com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(thisNotice,null,null,null);

obj.load("IFRQ_Number");

String IFRQ_Number= (String) obj.get("IFRQ_Number");

Thanks,

Kaushik

Re: Add a Custom Attribute to a specific task in Workflow

Hi,

Thanks for the help. I dropped that code in my expression robot and hit check syntax and got the following (see image) im not sure how to fix it:

Remy Variable to Attribute Mapping_1.PNG

Re: Add a Custom Attribute to a specific task in Workflow

is IFRQ_Number already defined as a workflow process variable? If so drop the String declaration in your code snippet.

If you want to set the value back to the Change Task you need to have an attribute for it. You would use the sequence of:

obj.load("IFRQ_Number"); // assumes that this is what the attribute is called in your Change Object

obj.set("IFRQ_Number", myProcessVariable); //assumes that myProcessVariable is defined in your workflow and is the same data type as IFRQ_Number

obj.apply();

// then you need to update the Change Object

wt.fc.PersistenceHelper.manager.modify(thisNotice);

Re: Add a Custom Attribute to a specific task in Workflow

Hi Kier,

Both my Variable and the attribute on the Change notice are called "IFRQ_Number" and both are of type string.

I tried some of the updates and am still getting a syntax error (see image):

Remy+Variable+to+Attribute+Mapping_2.PNG

Re: Add a Custom Attribute to a specific task in Workflow

ok then change the set statement to

obj.set("IFRQ_Number", IFRQ_Number);