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

Conditional routing based on Document attributes

SOLVED
Level 7

Conditional routing based on Document attributes

Hello all,

I am trying to have a conditional routing in a workflow, based on a specific attribute of the routed document.

In the expression I use this:

//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];
if (val.getDefinition().getName().equals("contracttype")) IPselect= val.getLocalizedDisplayString();
break;
}
}
}catch(Exception e) { System.out.println("Caught Exception:" + e.toString()); }

Then in the OR I have put this:

result="IP_Yes";

if (IPselect.equalsIgnoreCase("Consulting")) result="IP_No";

if (IPselect.equalsIgnoreCase("Service Agreement")) result="IP_No";

The problem I have is that some times it gets the value from the document (thus "IPselect" has a value in the workflow) and some others not.

Any ideas?

Thank you in advance

John

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Conditional routing based on Document attributes

It is solved. I found the error.

Originally I was telling to check this:

              

                if (val.getDefinition().getName().equals("contracttype")) IPselect= val.getLocalizedDisplayString();

                break;

So the if was break at the first attribute it was getting (any attribute). Obvisously it was not the one i wanted. So I have put the break inside like that:

                if (val.getDefinition().getName().equals("contracttype")) {

                IPselect= val.getLocalizedDisplayString();

                break;

                }

So now it will check all the attributes, and it will stop when it will get the "contracttype".

Regards

John

7 REPLIES

Re: Conditional routing based on Document attributes

Thank you for your comment.

The problem is that when the process run, sometimes I get the value of the attribute and sometimes not.

Regards

John

Re: Conditional routing based on Document attributes

It is solved. I found the error.

Originally I was telling to check this:

              

                if (val.getDefinition().getName().equals("contracttype")) IPselect= val.getLocalizedDisplayString();

                break;

So the if was break at the first attribute it was getting (any attribute). Obvisously it was not the one i wanted. So I have put the break inside like that:

                if (val.getDefinition().getName().equals("contracttype")) {

                IPselect= val.getLocalizedDisplayString();

                break;

                }

So now it will check all the attributes, and it will stop when it will get the "contracttype".

Regards

John

Re: Conditional routing based on Document attributes

Good for:

- keeping all brain cells really busy and working hard

- keeping us all humble

How good you feel when you find the problem seems to be in proportion to how hard it is to find the problem.

Re: Conditional routing based on Document attributes

Ioannis Psomiadis‌,

You may want to consider switching over from wt.iba.value.IBAHolder to com.ptc.core.lwc.server.PersistableAdapter.  I think your code is being deprecated.  And the new code is fewer lines.  Check it out in the context of the other posting:  Re: PBO Attribute captured in a workflow

doc = (wt.doc.WTDocument)primaryBusinessObject;  // you can skip this - you already instantiated "doc"

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

obj.load("contracttype");

IPselect = (String)obj.get("contracttype");

Re: Conditional routing based on Document attributes

Happy New Year Ben,

Thank you for your tip. I will test it in our development environment and I will let you know.

Regards

John

Re: Conditional routing based on Document attributes

Hello Ben,

 

I have tried to use the persistable adapter in a new promotio request workflow.

the code is as per below:

 

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()); }

 

The ditatype nevertheless in the workflow is empty. it does not get the value of the object.

Spelling is triple-checked Smiley Happy and i cannot understand why is that happening.

 

after the robot, i have the conditional expression:

if (ditatype.equalsIgnoreCase("BOM Engineering")) result="Engineering";
if (ditatype.equalsIgnoreCase("BOM Package")) result="Engineering";
if (ditatype.equalsIgnoreCase("Design Visual")) result="Design";
if (ditatype.equalsIgnoreCase("Mechanical Properties")) result="Engineering";
if (ditatype.equalsIgnoreCase("Package Material")) result="Package";
if (ditatype.equalsIgnoreCase("Part Material and Masterbatch")) result="Engineering-Technical";
else result="KDM-QA";

 

but it is always selecting the KDM-QA branch of the workflow.

 

any ideas?

 

Thank you in advance