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

Retrieving a Attribute from an Object Using an Expression in a Workflow

SOLVED
Newbie

Retrieving a Attribute from an Object Using an Expression in a Workflow

Hi All,

I need to retrieve an attribute ("Operation") which which I have added to a Change Notice in a workflow expression - since the value of this attribute alters downstream activities.

So far I have got as far as:

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

String coOperation = ...

Also by using the above code, does it matter that I want to retrieve the attribute from a soft type of the change notice.

Any help would be great.

Toby

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

You can try the code below as it works fine -

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

wt.iba.value.IBAHolder ibaHolder1 = (wt.iba.value.IBAHolder)cm1;

ibaHolder1 =wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainer(ibaHolder1, null, null, null);

wt.iba.value.DefaultAttributeContainer attributeContainer =(wt.iba.value.DefaultAttributeContainer) ibaHolder1.getAttributeContainer();

wt.iba.definition.service.StandardIBADefinitionService defService = new wt.iba.definition.service.StandardIBADefinitionService();

wt.iba.definition.litedefinition.AttributeDefDefaultView attributeDefinition = defService.getAttributeDefDefaultViewByPath("PhoneNumber"); //Here give the attribute name instead of "PhoneNumber".

wt.iba.value.litevalue.AbstractValueView svc = attributeContainer.getAttributeValues(attributeDefinition)[0];

IBAValue_PhoneNumber = svc.getLocalizedDisplayString();

24 REPLIES 24

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

It would help to learn the wt.query and wt.fc packages. Short of that, just use info engine.

public static Group test(WTObject primaryBusinessObject) throws Exception {

String instance = WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");

IeService service = new IeService();

ObjectWebject webject = new ObjectWebject("QUERY-OBJECTS");

webject.setService(service);

webject.setParam("INSTANCE",instance);

webject.setParam("OBJECT_REF",PersistenceHelper.getObjectIdentifier(primaryBusinessObject).getStringValue());

webject.setParam("ATTRIBUTES","*");

webject.invoke();

Group group = webject.getService().getGroup();

return group;

}

group.getAttributeValue(0, "Operation");

p.s. Don't hardcode this inside an expression. And it has to run on the MethodServer. Your servlet engine won't like it.

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

We do this very often in many workflow templates, without using webjects - just need simple Java code.


But - In 10.0, check out the new GUI-based way to do this that is available - very nice.

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

We do this very often in many workflow templates, without using webjects - just need simple Java code.


But - In 10.0, check out the new GUI-based way to do this that is available - very nice.

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

Hi Mike,

Currently we are only on 9.1 (need a proE upgrade first), so will not be getting 10.0 for about another year. So if you can do it in a workflow then can you please tell me the java expression I need? Or at least where precisely I should be looking.

Also, is the Windchill Javadoc the only means of learning the packages as Matthew has suggested I do?

Regards,

Toby

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

I know of two other ways to retrieve IBA values.

1. Would be to write your own queryspec, joining your pbo to the *value table, and joining that to the *definition table.

2. Uses your pbo's AttributeContainer, and retrieves the AttributeDefDefaultViews and AbstractValueViews.

1 is the approach we use when writing reports. 2 is the approach we use when dealing with single objects where we want to get/set values, but involves lots of code.

Mike, can you share your method?

Toby, you're kind of in a tough spot if you don't have an expert on hand. When I'm trying to figure something new out, I'll usually start with looking into how PTC does it. Knowing how they structure their packages and name their classes helps.

If you were doing something with documents, you may start by looking in the wt.doc package. There you'd find wt.doc.WTDocumentHelper.

If you were doing something with parts, you may start by looking in the wt.part package. There you'd find wt.part.WTPartHelper

If you were doing something with access control, you may start by looking in the wt.access package. There you'd find wt.access.AccessControlHelper

Beyond that, "helpers" often have "managers" or "services." So you could end up with WTDocumentHelper.service.* etc

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

I've been browsing the Javadoc and it is helping a lot. I'm sort of okay if I know what I am looking for.

These questions I am asking are generally related to my "Wish List" of features I want to add but are not a necessity for this initial implimentation, they will just make administration easier in a number of ways. I do therefore have time to get to grips with this (I have only known what Windchill is for a month and a half and been using it for a month). My only problem is where to get the knowledge from without running a big consultancy bill up.

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

I found this on another post (http://communities.ptc.com/message/165328):

wt.fc.QueryResult qr = null;

wt.doc.WTDocument RCIDFDoc=((wt.doc.WTDocument)primaryBusinessObject);

ext.generic.util.IBAUtil objHelper = new

ext.generic.util.IBAUtil(RCIDFDoc);

ApplicationNum=objHelper.getIBAValue("ApplicationNum");

BusinessCategory=objHelper.getIBAValue("BusinessCategory");

EstimatedNetSales=objHelper.getIBAValue("EstimatedNetSales");

FGNum=objHelper.getIBAValue("FGNum");

I tweaked this to the following:

result = "NAY";

wt.fc.QueryResult qr = null;

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

ext.generic.util.IBAUtil objHelper = new ext.generic.util.IBAUtil(co);

String selectedOption=objHelper.getIBAValue("UpdateJobs");

if (selectedOption.equals("No")) {

result = "YAY";

}

It came up with no errors when I first compiled it, I tested it, it failed, now when I compile it it comes up with the following error:

Checking Syntax...

/apps/ptc/Windchill_9.1/Windchill/tmp/WfExpression8906920.java:39: package ext.generic.util does not exist

ext.generic.util.IBAUtil objHelper = new ext.generic.util.IBAUtil(co);

^

/apps/ptc/Windchill_9.1/Windchill/tmp/WfExpression8906920.java:39: package ext.generic.util does not exist

ext.generic.util.IBAUtil objHelper = new ext.generic.util.IBAUtil(co);

^

2 errors

Syntax check complete.

It give anyone any ideas?

Highlighted

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

ext.generic.util.IBAUtil was something custom they created. It's not OOTB, as far as I know

Re: Retrieving a Attribute from an Object Using an Expression in a Workflow

I think you are right, I have seen that kind of thing referenced a number of times and it definitely is not a package in our system.

Announcements

Thingworx Navigate content has a new home! Click here to access the new Thingworx Navigate forum! ______________________________ Check out the Windchill Tips Board! We're talking about Whirlpool's use of digital twin, augmented reality, and data-driven design!

The NAVIGATE WORKING GROUP is here! Come innovate with PTC!

Sign up for a Working Group