Skip to main content
16-Pearl
December 29, 2016
Solved

PBO Attribute captured in a workflow

  • December 29, 2016
  • 2 replies
  • 2810 views

Looking for assistance with code that will grab a custom attribute value created using T&AM and write it to a variable in a workflow...Then using a custom email template I'll be able to display that value in the email.  Not a code guy at all...thanks!!!

WC10.2 M030 CPS 17

Greg

Best answer by BenPerry

Greg Olson‌,

I just want to narrow in on the use case to make sure I understand your scope.  You have a workflow generated from a Change object, for example?  And you want to grab the value of an IBA that exists on the PBO (the Change object, for example)?

This is documented through WHC.  But I have gone through it extensively in the last couple of months.  So I can help you if you have any trouble interpreting the WHC article.  Search for "working with PBO attributes" in WHC.

Below is an example from my use case.  This code is in Execute Expression robot in the workflow template.  The PBO in my case is a WTDocument actually - not a Change object.

doc = (wt.doc.WTDocument)primaryBusinessObject;

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

obj.load("myIBAsInternalNameHere");                                   // this is the internal name of the IBA

myWorkflowVariableHere = (String)obj.get("myIBAsInternalNameHere");   // assuming myWorkflowVariableHere has already been instantiated somewhere previous

2 replies

BenPerry15-MoonstoneAnswer
15-Moonstone
December 29, 2016

Greg Olson‌,

I just want to narrow in on the use case to make sure I understand your scope.  You have a workflow generated from a Change object, for example?  And you want to grab the value of an IBA that exists on the PBO (the Change object, for example)?

This is documented through WHC.  But I have gone through it extensively in the last couple of months.  So I can help you if you have any trouble interpreting the WHC article.  Search for "working with PBO attributes" in WHC.

Below is an example from my use case.  This code is in Execute Expression robot in the workflow template.  The PBO in my case is a WTDocument actually - not a Change object.

doc = (wt.doc.WTDocument)primaryBusinessObject;

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

obj.load("myIBAsInternalNameHere");                                   // this is the internal name of the IBA

myWorkflowVariableHere = (String)obj.get("myIBAsInternalNameHere");   // assuming myWorkflowVariableHere has already been instantiated somewhere previous

17-Peridot
January 3, 2017

Greg,

Here is the Help for how to access Type managed attributes from the PBO in workflow

http://support.ptc.com/cs/help/windchill_hc/wc110_hc/index.jspx?id=WFExecExprRobotSampleModAttr&action=show

As in Ben's example it uses com.ptc.core.lwc.server.PersistableAdapter.  If you are using an version of Windchill older then 10.2 the API had a different name - it was LWCNormalizedObject

GregOlson16-PearlAuthor
16-Pearl
January 3, 2017

Thanks for the information, I was able to come up with code for the exp robot based on our consultants and Ben's help!

com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter((wt.fc.Persistable)primaryBusinessObject,null,java.util.Locale.US,null);
obj.load("IBAInternalName");
"Variable"= (String)obj.get("IBAInternalName");