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

Where to write the code?

SOLVED
Highlighted
Pearl

Where to write the code?

Tell me please where to write the code https://www.ptc.com/en/support/article?n=CS150777 , tried many options, but failed nothing. Here is the code to add a table to the page

Description

How to add Promotion Objects to the Instructions field on the task's details page

User should see all the objects being promoted on the same page to avoid multiple clicks for navigating to the Promotion Objects page

How to add Promotion Target Objects in workflow Email Notification

 

Resolution

  1. Create global variable (say var of type String)
  2. Before activity add expression robot
  3. Append string to have all the promotion objects' numbers/names
  4. In activity create local variable
  5. Use that local variable in instructions
  • Following code can be used to get the promotion target objects

​wt.maturity.PromotionNotice notice = (wt.maturity.PromotionNotice)primaryBusinessObject;
                 wt.fc.QueryResult results = wt.maturity.MaturityHelper.service.getPromotionTargets(notice);
                 while (results.hasMoreElements())
                  {
                          obj = results.nextElement();
                          if (obj instanceof wt.doc.WTDocument)
                          {                                 
         var += obj.getName ()+“,”;         // var  is a global variable
                          }
                     }

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted

Re: Where to write the code?

2019-10-10 11_18_59-00 Process.png

 

Hope this helps. The local variable should be initialized from the global variable. Local variables are only needed for activities, not for robots (like expression or email robot).

View solution in original post

15 REPLIES 15
Highlighted

Re: Where to write the code?

2019-10-10 11_18_59-00 Process.png

 

Hope this helps. The local variable should be initialized from the global variable. Local variables are only needed for activities, not for robots (like expression or email robot).

View solution in original post

Highlighted

Re: Where to write the code?

yadavankur, thank you very much, tell me, is it in the template Promotion Request Review Process should be written or in another? And how to check that the attempt was successful?

Highlighted

Re: Where to write the code?

Assuming your Windchill is completely out of the box, you will set up the code and the variable in the two Promotion processes that PTC provides. If you are not sure check promotion preference management under site>utilities and org>utilities If you want to use the variable in a workflow activity instruction you would use it like this {myLocalVariable} to check your attempt you will create a promotion and view the instructions on the task that you receive. Here are two example variable in use in a notification robot (not in activity).Variable.PNG

Highlighted

Re: Where to write the code?

clipboard_image_0.png

This all that there is in the list, in every tried on Your instructions to do, but nothing not is changing, I something do not so ?

Highlighted

Re: Where to write the code?

02.jpg13.jpg45.jpg

Re: Where to write the code?

Hi Vlad,

 

Now add your variable under the "Promotion Object table" text in curly braces:

 

5. Promotion Object table:

{MyValue}

 

Now when the task is generated the instructions will display the value of the variable. Be sure to also initialize your MyValue variable. Select the appropriate process variable (in your example it's name "var") in the "Initialize From" dropdown.

Highlighted

Re: Where to write the code?

Yep, that should do it, the initialize from and the parenthesis. Also Vlad, you have checked out all the workflows, I would suggest you check them in if they have the change you want or undo-checkout if you don't need them. Like I said earlier, if you do not know which workflow you want to modify, check the site>utilities>promotion preference management.

Highlighted

Re: Where to write the code?

Hello, Yadavankur, opened Promotion Preference Management. How to use them to understand what template is needed?

1.JPG2.JPG

Highlighted

Re: Where to write the code?

I can't read Cyrillic (assuming it is Cyrillic), but what you have under Current Processes: are the two processes you should be modifying. The Life Cycle State for Promotion is the state user picks when promoting the object, and the workflows are the two options. You have another Preference for All states, and therefore it might be the one more applicable to your case, not the Test18 In Analysis one that you have highlighted, unless you are testing those workflows only.

Highlighted

Re: Where to write the code?

yadavankur, thank you, the right template was found, but now there is a problem with the code. Tell me, please, what type should have a variable obj ? I've tried every type I know, but I haven't passed the test

 

Checking Syntax...
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_11.java:54: error: cannot find symbol
obj = results.nextElement();
^
symbol: variable obj
location: class WfExpression_11
WfExpression_11.java:55: error: cannot find symbol
if (obj instanceof wt.doc.WTDocument)
^
symbol: variable obj
location: class WfExpression_11
WfExpression_11.java:57: error: cannot find symbol
var += obj.getName ()+","; // var is a global variable
^
symbol: variable obj
location: class WfExpression_11
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
3 errors
1 warning

Syntax check complete.

Highlighted

Re: Where to write the code?

Try wt.fc.Persistable:

 

wt.fc.Persistable obj = results.nextElement();

Highlighted

Re: Where to write the code?

 

zsternal-2, thanks for your suggestion, but it still didn't work out (

 

Checking Syntax...
warning: Supported source version 'RELEASE_7' from annotation processor 'com.microsoft.azure.management.apigeneration.LangDefinitionProcessor' less than -source '1.8'
WfExpression_11.java:57: error: incompatible types: Object cannot be converted to Persistable
obj = results.nextElement();
^
Note: WfExpression_11.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
1 warning

Syntax check complete.

Highlighted

Re: Where to write the code?

Okay! Try using Object then:

 

Object obj = results.nextElement();

 

And if that doesn't work use java.lang.Object.

Highlighted

Re: Where to write the code?

 

zsternal-2, tried, but the result is the same
Highlighted

Re: Where to write the code?

Hello, Zsternal,I initialized the variable and added it under the text " 5. Promotion of the Object table". Kept the template, but nothing has changed. I did everything only in the template "Promotion Request Review Process", did I choose the template correctly?

Announcements