Numbering for Parts Owned by Multiple Organizations
The following is an example rule XML fragment that switches between two numbering schemes based on the organization that owns the part. The scheme for Org1 produces numbers such as PRT-1234567 while the scheme for Org2 produces numbers such as 12345-PRT.
* 
In the example that follows, some XML elements span multiple lines because of the page width. When coding an XML document, enter each XML element on one line.
<!-- Define a numbering scheme for Org1 -->
<VarDef id="Org1-GeneratedNumber" algorithm=
"com.ptc.windchill.enterprise.revisionControlled.server.impl. NumberGenerator">
<Arg>PRT-</Arg>
<Arg>{GEN:wt.enterprise.SequenceGenerator:ORG1_WTPARTID_seq:7:0}</Arg>
</VarDef>

<!-- Define a numbering scheme for Org2 -->
<VarDef id="Org2-GeneratedNumber" algorithm="
com.ptc.windchill.enterprise.revisionControlled.server.impl. NumberGenerator">
<Arg>{GEN:wt.enterprise.SequenceGenerator:ORG2_WTPARTID_seq:5:0}</Arg>
<Arg>-PRT</Arg>
</VarDef>

<!-Set the number attribute using the appropriate scheme defined above -->
<AttrValue id="number" algorithm="wt.rule.algorithm.StringConstant">
<Value algorithm="wt.rule.algorithm.BooleanBranch">
<Value algorithm="wt.rule.algorithm.OrgNameEqualsTest">
<Attr id="organization.id"/>
<Arg>Org1</Arg>
</Value>
<VarRef id="Org1-GeneratedNumber"/>
<VarRef id="Org2-GeneratedNumber"/>
</Value>
</AttrValue>
In this example, each numbering scheme is based on a different sequence. Since a VarDef element is not evaluated unless a corresponding VarRef element is evaluated, only one number is ever generated. Therefore, as parts are created for the two organizations, the numbers should be assigned sequentially. For example, if both sequences start at 1, the numbers would be assigned as follows:
Create part owned by Org1: PRT-0000001
Create part owned by Org2: 00001-PRT
Create part owned by Org2: 00002-PRT
Create part owned by Org1: PRT-0000002
As expected, no gaps appear in the numbering sequence for either organization.
È stato utile?