Change the numbering pattern of an object based on another attribute

Based on an attribute value, change the numbering pattern of an object type.
[How to use Switch-Case in OIR]
[How to put conditions in OIR]

Add Comment
1 Answer(s)

If we want to customize the naming pattern of an object based on business conditions, we can do it by making use of CaseBranch, BooleanBranch or EqualsTest.

CaseBranch algorithm in OIR, provides the functionality similar to Switch-Case used in Java. Similarly, EqualsTest is used to compare two values for equality.

For eg.

<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
 <!-- CaseBranch starts here -->
 <Value algorithm="wt.rule.algorithm.CaseBranch">
 
  <!-- If name entered by user equals to One, then number is assigned the value of Source attribute  -->
  <Value algorithm="wt.rule.algorithm.EqualsTest">
   <Attr id="name" />
   <Arg>One</Arg>
  </Value>
  <Attr id="source" />
  
  <!-- If name entered by user equals to Two, then number is assigned the value of Container Name -->
  <Value algorithm="wt.rule.algorithm.EqualsTest">
   <Attr id="name" />
   <Arg>Two</Arg>
  </Value>
  <Attr id="containerName" />
  
  <!-- If none of the above cases are true then the default value is assigned to the number attribute -->
  <Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
 </Value>
</AttrValue>

 

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.