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

We are happy to announce the new Windchill Customization board! Learn more.

Retrieving a standard attribute value Windchill 10.1

ptc-4736081
1-Newbie

Retrieving a standard attribute value Windchill 10.1

I want to retrieve a Standard Attribute value created over promotion request thorugh code. can some one help with this?

20 REPLIES 20

Hi Sumit,

I am actually working on the same thing. Have you gotten any further since posting? I found this discussion which may be of some help if you haven't yet gotten it: http://communities.ptc.com/message/182669

What attribute are you looking for specifically? Is it an IBA? Are you doing this in a workflow?

I'm not sure about Sumit, but I'm looking for the "description" for the promotion request. Yes, I'm looking to do this in a workflow. I'm afraid I don't know what IBA stands for . Also, I'm looking to add the names of the collected objects of the promotion request in the Approval Notification email - do you know if this is possible? I should note that I'm running 9.1, not 10.1 as Sumit is.

If it is in the Promotion Notice workflow , you can just put

String desc = ((wt.maturityPromotionNotice)PrimaryBusinessObject).getDescription()

primarryBusinessObject is the object who"lived" in the worklfow, and Description is a standard attribute, not an IBA, so you can directly access to it by a get method

Thank you so much! To make sure I understand perfectly, this line of code does not need to be entered as a variable, it can simply be entered directly into one of the text boxes for a notification email?

Thanks again!

No you can't use java code in a mail robot

need to use it in a robot expression and use the variable like for example {myString}

What is the Type Name that should be used? java.lang.String? I tried this but it didn't seem to work. Perhaps I've implemented it incorrectly somehow...

Create a global workflow variable java.lang.String "myString"

In a expression robot, add: String myString = ((wt.maturityPromotionNotice)PrimaryBusinessObject).getDescription();

In the body of the mail robot: add your message and the variable

{myString}

When entering that information, if I hit the "check syntax" button I get the following:

Checking Syntax...

C:\ptc\Windchill_9.1\Windchill\temp\WfExpression_Administrator.java:29: cannot find symbol

symbol : class maturityPromotionNotice

location: package wt

myString = ((wt.maturityPromotionNotice)primaryBusinessObject).getDescription();

^

1 error

Syntax check complete.

This is if I omit "String" in the code provided above. If I include "String" as per above, I get 2 syntax errors. If you try to duplicate this, note that PrimaryBusinessObject should have a lowercase "p".

Thanks in advance.

I'm not following this thread, but I can see that there's a small typo. I'm guessing you should change "wt.maturityPromotionNotice" to "wt.maturity.PromotionNotice" (or whatever the correct package/classname is)

sorry for the typo !

Thank you so much you guys, this does work!

Now if I can just clean up the notification emails a bit the recipients wouldn't have to read through most of the junk to find the description...

Is it correct to say that the notification email for the promotion activity assigned task can be modified by going to the Site --> Templates tab, selecting Activity Forms, and then editing the Promotion Notice Task Form Template? I see that this changes what a Promotion Approver sees, but it doesn't look to be changing the notification emails (unless I haven't modified the right part).

Thanks again for helping me with the description, that is excellent! You guys are great!

I don't think you can change the Email look and feel OOTB. It should be possible by customization.

Cause as you say, you can change the look and feel of the workflow task by itself. But the email is just a check box option , in order to send an email , when the task is started...

You can add in the Promotion worklfow, your own Email robot, where you can easily define message , variables ... but not the look and feel if I remember ....

regards

Greg, do you know where I would be able to find a list of commands like the "getDescription()" command above?

I need to conditionally route the workflow to different notification emails based on the Product Name.

Thanks!

all the commands (method in java 😉 )

are in the API. you can download at PTC.com, for example for 10.1M030

http://www.ptc.com/appserver/wcms/standards/fileothumbredirect.jsp?&im_dbkey=152452&icg_dbkey=522&lang=fr

but some of the method are not documented in the API. In some developement JAVA tool, like eclipse, you can have auto completion that can help you to find the method...

Thank you! The API has helped me already!

However, it has stumped me too: I'm trying to avoid creating promotion workflows at the Product level, but we have products that require different paths in a workflow. I'm using 9.1 M040 and from what I can tell there is no "getProductName" or "getContext" under the wt.maturity.PromotionNotice class. I have found a getName under wt.pdmlink.PDMLinkProduct, but when I tried to implement that the workflow process stopped at that expression node. When I opened the Process Manager, I found a slew of errors associated with the variable, cut/pasted below:

Errors: wt.util.WTException: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: wt.util.WTException: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

wt.workflow.engine.FailedExpressionException: wt.util.WTException: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: wt.util.WTException: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

Nested exception is: java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.pdmlink.PDMLinkProduct

at wt.workflow.expr.WfExpression2362903.execute_ROBOT_EXPRESSION_(WfExpression2362903.java:33)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

at java.lang.reflect.Method.invoke(Method.java:597)

at wt.workflow.definer.WfExpression.executeTransition(WfExpression.java:2511)

at wt.workflow.definer.WfExpression.execute(WfExpression.java:1099)

at wt.workflow.robots.WfExpressionRobot.run(WfExpressionRobot.java:363)

at wt.workflow.engine.StandardWfEngineService.runRobot(StandardWfEngineService.java:951)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethod

Is there any way to capture the Product Name of the PBO so I can use it as a variable for conditional routing?

Thanks!

You should be able to do that (where doc can be a WTpart , doc, EPMDoc, so kinds of objects that will typically managed in a promotion request)

do get the organization

String org = doc.getOrganizationName();

to get the container name

String container = doc.getContainerName();

be carrefull you try to cast the PBO (the promotion request which live in the workflow) into a product

try to use the getContainerName() on the PBO

String containerName= ((wt.maturity.PromotionNotice)pbo).getContainerName();

Hi Matthew,

I would like to write an expression on the Routing Expression window that will route the workflow based on the value of an IBA of the pbo which is a subtype of the WTDocument. Can you please assist.

Regards,

Tshepo

KD
4-Participant
4-Participant
(To:TshepoMokhere)

Declare a variable of proper data type globally.

After that fetch the IBA value to that variable.

Inside a conditional robot write something like

if(ibaValue == "val1")

result="route1";

else

result="route2";

Thanks and Regards,

Kaushik

Top Tags