Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
Solved! Go to Solution.
I used the check syntax command and I did not have any syntax errors. However, I will try the double equal sign. It may be they are both allowable, but each has a different purpose. I am only hypothesizing, as I have only the experience I gained from my mistakes yesterday.
standard stuff
1. Create a workflow variable and have set near the beginning of the workflow, probably by a user via an activity
2. Use that variable value in any number of conditionals later in the workflow to branch the flow.
That's great... unfortunately, I don't have the experience with the coding to do this. So if anyone reads this post who does have that experience and can create some sample code for me to play with, I will be eternally grateful.
How are things in this area lately? Still need help?
1) Create a variable in the workflow of type boolean.
2) Write your question name in the display name of that variable.
3) Add this variable to the activity you want, where it will be answered.(Will be ticked if yes)
4) Now the answer i.e. Yes or No will be saved in the boolean variable.
5) When you want to use it for further routing you can put a conditional block-
Select the Routing type- Conditional.
The Code is-
if(Userip.equals("Inhouse"))
result="Production";
else if(Userip.equals("Outsourced"))
result="Procurement";
else
result="Both";
6) Here Userip is my variable Name.
And the options provided in result should be provided in Roting Events.
Hi Dhanashri,
How can I use the conditional connector to route the process relative to a value returned from the primarybusiness object's attribute.
Regards and Thanks
1) You can create a variable in your workflow eg-IBAValue_EnggFuntion and use the below code to get the attributes of Primary buisness object. The first line of the code depends on the type of your buisness object in this case it is a problem report. In the code below the ViewByPath given is "Engineering_Function", this is the name of the attribute whose value you want to capture.
2) Once you get the attribute value in your workflow variable you can use that variable in conditional connector to route the process.
/*************Code**********************/
wt.change2. WTChangeIssue cm1 = (wt.change2.WTChangeIssue) 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("Engineering_Function");
wt.iba.value.litevalue.AbstractValueView svc = attributeContainer.getAttributeValues(attributeDefinition)[0];
IBAValue_EnggFuntion = svc.getLocalizedDisplayString();
Hi Dhanashri,
Firstly; what should I select by the Type Name, when creating the variable?
Secondly; I have a soft type for the type "Reference Document" and the object type name is as follows:
wt.doc.WTDocument|com.ptc.ReferenceDocument|ZA.CO.ROUTEHOLDINGS.SATBOrder
I understand that I need to give the attribute name at the view by path. Is this the only place in the code that I change? does everything else stay the same?
Thanks
Hi Dhanashri,
I would like to use the code above for getting the "Description" attribute from a promotion request. Would I simply use "Description" as my ViewByPath and the following for my first line of code?
wt.maturity.PromotionNotice cm1 = (wt.maturity.PromotionNotice) primaryBusinessObject;
Thanks in advance!
-Ben
That is very helpful. I can rename the variable and the results, but I still don't know how to set the variable in the first place and where.
You can define the variable globally by defining it in properties, when you edit a workflow template.
I have attached the screenshots..
Thanks. I had already spent some a lot of time doing research and found this answer, but at least I know that someone else is willing to help.
I now have a variable that I can reset and call in conditional routing, however, for some reason, I still can't get the routing to vary.
I created a boolean, and if its true I go one direction and all else I go another. I think I have the coding wrong somehow, as no matter what I choose, it only goes one direction.
code:
if(test=true)
result="R&D"
else
result="Released"
if test is checked or unchecked in the activity set to change it, it still only goes to R&D, if I change true to false, it only goes to Released. I even view test in the activities following the change to ensure it has not changed.
syntax error - need double ==
Use the "check syntax" command.
Look at the (very few) examples of workflow code provided by PTC in the help.
I used the check syntax command and I did not have any syntax errors. However, I will try the double equal sign. It may be they are both allowable, but each has a different purpose. I am only hypothesizing, as I have only the experience I gained from my mistakes yesterday.
Here is one sample from PTC's help. Note the double == used in an IF expression.
A single = is assignment of a value to a variable.
A double == is a comparison operator.
if ((( wt.lifecycle.LifeCycleManaged )primaryBusinessObject). getLifeCycleState( )== wt.lifecycle.State. < life cycle state>) result= "< routing event >"; else result= "< routing event >";
Thank you Mike. That is exactly what I was needing. You saved me possible hours of searching for the issue. I thought it might be a syntax issue, though not a syntax error and I figured it had to do with the if statement because of the way the routing was acting.
Thank you all for all your help. If anyone is interested I can post the results. I was able to creat a singlr workflow to handle all my promotions.
Hi ShawnPete,
Yes, if you could post the results that would be helpful! Thanks!
The following image is the resulting workflow. The resultant ZIP is posted to allow others to view the coding.