Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I am using Windchill PDMLink Release 12.1 and Datecode with CPS 12.1.0.1
How to set a different number ( concatenation of attributes) according to a different IBA value ?
Solved! Go to Solution.
Hi @FL_12115481
You have wrong test element.
Because there are two different types - string and Boolean the calculation can not be done by this Test method
You have to use the StringEqual test and it will work as you need
example>
<VarDef id="GeneratedNumberConfigurable" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Attr id="STRINGINPUT"/>
<Attr id="RNUMINPUT"/>
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:3:0}</Arg>
</VarDef>
<!-- set the number to a generated number -->
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Arg>30W</Arg>
<!-- add a V prefix for variant parts -->
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="UTC_CONFIGURABLE"/>
<Arg>true</Arg>
</Value>
<VarRef id="GeneratedNumberConfigurable" />
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
</Value>
<!-- the sequence -->
<Arg></Arg>
</AttrValue>
The real number input also works
PS: the error is clear. You compare boolean type value true with string value "true" and the method can not do that.
That is why the method throws the error "there are two different type arguments".
PetrH
Hello mwaite, thanks a lot for your answer.
The problem I am facing is how to combine multiple attributes in the EqualsTest algorithm. If I try to insert more than one ARG Tag the system gives me an error. Apparently with the boolean branch algorithm you can just set a preferix or a different progressive number.
Below an example to make it more clear :
Hi @FL_12115481
By the Boolean branch you can add more attributes. but you just need to repeated the Boolean branch as an another condition
btw in the boolean branch never ever leave empty rows...
<!-- set the number to a generated number -->
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Arg>30W</Arg>
<!-- add a V prefix for variant parts -->
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.EqualsTest">
<Attr id="IBA|UTC_CONFIGURABLE"/>
<Arg>true</Arg>
</Value>
<Arg>FIRST ARG IN THE CONDITION</Arg> <!-- true -->
<Arg></Arg> <!-- false - nothing to add-->
</Value>
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.EqualsTest">
<Attr id="IBA|UTC_CONFIGURABLE"/>
<Arg>true</Arg>
</Value>
<Arg>NEXT ARG IN A ROW...</Arg> <!-- true -->
<Arg></Arg> <!-- false - nothing to add-->
</Value>
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.EqualsTest">
<Attr id="IBA|UTC_CONFIGURABLE"/>
<Arg>true</Arg>
</Value>
<VarDef id="GeneratedNumberConfigurbale"/> <!-- true -->
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg> <!-- false - generate the auto number-->
</Value>
</AttrValue>
PS> please share the error that was thrown in your case.
PetrH
Hi HelesicPetr,
how can I insert the value of an IBA inside the ARG Tag?
<Arg>FIRST ARG IN THE CONDITION</Arg>
Hi @FL_12115481
instead of a row
<Arg>FIRST ARG IN THE CONDITION</Arg>
use
<Attr id="IBA|UTC_CONFIGURABLE"/>
<Arg> element contains just string constant
<attr> contains the attribute
PetrH
If I use the <Attr id ="IBA|UTC_CONFIGURABLE"/> or the <VarRef id = "GeneratedNumberConfigurable"/> istead or the <Arg>...</Arg> , the system gives me this error :
Caused by: (wt.rule.ruleResource/611) wt.util.WTException: ATTENTION: An object initialization rule could not be applied because an error was detected. Report this issue to your administrator.
at com.ptc.core.rule.server.delegate.init.AttributeValuesHelper.getArgFilter(AttributeValuesHelper.java:259)
at com.ptc.core.rule.server.delegate.init.AttributeValuesHelper.getArgFilter(AttributeValuesHelper.java:246)
at com.ptc.core.rule.server.delegate.init.AttributeValuesHelper.getFilter(AttributeValuesHelper.java:179)
at com.ptc.core.rule.server.delegate.init.AttributeValuesHelper.getFilter(AttributeValuesHelper.java:100)
Apparently in the Boolean Branch you can use just the Arg tag.
Federico
Hi @FL_12115481
Are you sure that the attribute definition is correct?
I am not sure if the IBA xml definition should contain the string "IBA|"
check following article where the IBA prefix is not used
CS396081 - How to set OIR to select lifecycle template name based on IBA value
or CS186722 - How to set OIR to select folder name based on IBA value
try to use <Attr id ="UTC_CONFIGURABLE"/> instead o <Attr id ="IBA|........
PetrH
If I use <Attr id ="UTC_CONFIGURABLE"/> instead o <Attr id ="IBA|........ that's the error:
Caused by: (wt.rule.ruleResource/310) wt.rule.algorithm.InvalidAlgorithmArgumentException: Two arguments passed in are of different type.
at wt.rule.algorithm.EqualsTest.calculate(EqualsTest.java:119)
at wt.rule.algorithm.RuleAlgorithmHelper.calculate(RuleAlgorithmHelper.java:116)
at wt.rule.algorithm.RuleAlgorithmHelper.calculate(RuleAlgorithmHelper.java:74)
at com.ptc.core.rule.server.delegate.init.Utils.getValue(Utils.java:773)
at com.ptc.core.rule.server.delegate.init.Utils.getArgs(Utils.java:800)
at com.ptc.core.rule.server.delegate.init.Utils.getValue(Utils.java:773)
at com.ptc.core.rule.server.delegate.init.Utils.getArgs(Utils.java:800).
Are you sure is it possibile to insert the value of an attribute when you use the Boolean Branch algorithm?
Hi @FL_12115481
You have to use a condition if the Boolean branch expect Boolean type then you have to use String equal for String attribute to get the boolean type. .
<Value algorithm="wt.rule.algorithm.EqualsTest">
PetrH
Perhaps I wasn't clear . I need to build a code that is structured as follows.
In case of a configurable component:
30W+AttrValue1+AttrValue2+ProgressiveNumber
In case of a non-configurable component:
30W+progressiveNumber
since I use the Boolean Branch the system gives me the possibility to draw out only prefixes or progressive numbers as a result of the if.
Hi @FL_12115481
And where is the problem?
Just write the conditions in a correct order and you can achive what you have written.
You can use more boolean conditions...
PetrH
maybe you not understading.
When I use the boolean condition, system allow me to use as a result just a prefix or a progressive and not the Value of IBA.
Example:
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.EqualsTest">
<Attr id="genericType"/>
<Arg>standard</Arg>
</Value>
<Attr id="IBA|"/>
<Arg></Arg>
</Value>
If I use the <Attr id="IBA"/> after the tag </Value> the system give me and error.
look at the error I posted in the previous answers.
Attr1 is a Real Number and Attr2 is a String
I have the same error even if I use either of them.
@HelesicPetr do you have an example of oir where you use an AttrValue in the Boolean Branch algorithm?
Hi @FL_12115481
Here is example how to create own function to get an custom number.
You can see that the return value is String even though it is number
https://www.ptc.com/en/support/article/CS110198
PetrH
so I need a custom to do it. Thanks for your help
Hi @FL_12115481
You have wrong test element.
Because there are two different types - string and Boolean the calculation can not be done by this Test method
You have to use the StringEqual test and it will work as you need
example>
<VarDef id="GeneratedNumberConfigurable" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Attr id="STRINGINPUT"/>
<Attr id="RNUMINPUT"/>
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:3:0}</Arg>
</VarDef>
<!-- set the number to a generated number -->
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
<Arg>30W</Arg>
<!-- add a V prefix for variant parts -->
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="UTC_CONFIGURABLE"/>
<Arg>true</Arg>
</Value>
<VarRef id="GeneratedNumberConfigurable" />
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
</Value>
<!-- the sequence -->
<Arg></Arg>
</AttrValue>
The real number input also works
PS: the error is clear. You compare boolean type value true with string value "true" and the method can not do that.
That is why the method throws the error "there are two different type arguments".
PetrH
Hi @FL_12115481,
I wanted to see if you got the help you needed.
If so, please mark the appropriate reply as the Accepted Solution. It will help other members who may have the same question.
Of course, if you have more to share on your issue, please pursue the conversation.
Thanks,
Anurag