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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Conditional routing based on a global attribute of Dynamic Document

ipsomiadis
10-Marble

Conditional routing based on a global attribute of Dynamic Document

Hello all,

 

i have run successfully the code in the case bellow for a Document.

https://community.ptc.com/t5/Windchill/Conditional-routing-based-on-Document-attributes/m-p/189278#M22601

 

When applying the same code for a different object type, Dynamic Document, it does not record in the variable of the workflow the value of the attribute.

I have tried the following:

 

try {
wt.epm.EPMDocument doc =  (wt.epm.EPMDocument) primaryBusinessObject;

 

//get the attributes of the document.
wt.iba.value.IBAHolder holder = wt.iba.value.service.IBAValueHelper.service.refreshAttributeContainerWithoutConstraints(doc);
wt.iba.value.DefaultAttributeContainer ac = (wt.iba.value.DefaultAttributeContainer) holder.getAttributeContainer();

if (ac != null) {
wt.iba.value.litevalue.AbstractValueView[] avalues = ac.getAttributeValues();

for (int i=0;i<avalues.length;i++) {
    wt.iba.value.litevalue.AbstractValueView val = avalues[i];
    System.out.println("checking attribute: <" + val.getDefinition().getName() + "> with value= <" + val.getLocalizedDisplayString() + ">");
    if (val.getDefinition().getName().equals("com.bicworld.Type")) {
        ditatype= val.getLocalizedDisplayString();
        break;
    }
}
}
}catch(Exception e) { System.out.println("Caught Exception:" + e.toString()); }

 

I have also tried to use the Persistable Adapter as per below, but still the same problem.

try {

wt.epm.EPMDocument doc =  (wt.epm.EPMDocument) primaryBusinessObject;

com.ptc.core.lwc.server.PersistableAdapter obj = new com.ptc.core.lwc.server.PersistableAdapter(doc,null,null,null);
obj.load("com.bicworld.Type");
ditatype = (String)obj.get("com.bicworld.Type");

}catch(Exception e) { System.out.println("Caught Exception:" + e.toString()); }

 

Any idea why is that happening?

Thank you in advance

ACCEPTED SOLUTION

Accepted Solutions
Florent
15-Moonstone
(To:ipsomiadis)

I don't use the IBA API for a while, but I don't think the method "getLocalizedDisplayString()" is the right one (I would assume its name to be more something like getValue()).

Anyways, I suggest you to use the PersistableAdapter.

 

The reason might be somewhere else. Is you PBO really a DD / EPMDocument ?

 

Florent ROUSSEL
www.4cad.ca

View solution in original post

3 REPLIES 3
Florent
15-Moonstone
(To:ipsomiadis)

Hi,

 

I would suggest the second option.

Anyway, both should work (but I think you made a mistake in the first attempt, I think it should be value):

ditatype= val.getLocalizedDisplayString()

Did you tried to add some debug output (using System.out.println(...)) ?

 

PersistableAdapter persistableAdapter = new PersistableAdapter(persistable, null, Locale.US, null);
persistableAdapter.load(attrName);
apiReturn = persistableAdapter.getAsString(attrName);

 

Florent ROUSSEL
www.4cad.ca

Thank you for your reply, yes i have used debug output, but i cannot see anything in the logs.


When you say mistake in the first option, could you be more specific?

 

Thank you

Florent
15-Moonstone
(To:ipsomiadis)

I don't use the IBA API for a while, but I don't think the method "getLocalizedDisplayString()" is the right one (I would assume its name to be more something like getValue()).

Anyways, I suggest you to use the PersistableAdapter.

 

The reason might be somewhere else. Is you PBO really a DD / EPMDocument ?

 

Florent ROUSSEL
www.4cad.ca
Announcements

Top Tags