Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X
Hello Everyone
I want to create a product number based on attribute selection.
On selecting the attributes the product number has to be created automatically choosing the number given for the particular attribute.
For example:
Customer No. Product Family Running No.
XXX YY ZZZ
If the product attribute selection be like 032(Customer no.)12(Product family) 322(running no.)
The auto generated number should be like 03212322
I'm able to create the numbering schema for customer name using case branch in OIR. But I have no clue in combining both the customer no. as well as product family (XXXYYZZZ)
Can anyone help in this?
Any help is greatly appreciated.
Essentially what you're saying is that you have 2 attributes and a sequence. And you want the number of the object to be a concatenation of those 3 attributes. Is that what you're asking?
I can't remember where I got this code from. I think there is an article on it. But I couldn't find it doing a quick search. But I have a WTDocument OIR that will set the name as a concatenation based on 2 things:
<AttrValue id="name" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator" ignore="false" force="false" final="false">
<Attr id="partQualGenPartNumber"/>
<Arg>: PART QUALIFICATION PROCESS</Arg>
</AttrValue>
So if you wanted to set the number of the object based on 2 attributes and a sequence, perhaps something like this would work?:
<AttrValue id="name" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator" ignore="false" force="false" final="false">
<Attr id="customerNumberIBAinternalName"/>
<Attr id="productFamilyIBAinternalName"/>
<Attr id="runningNumber"/><Arg>{GEN:wt.enterprise.SequenceGenerator:YOUR_DATABASE_SEQUENCE:3:0}</Arg>
<AttrValue>
Thanks for your valuable reply sir.
Will try and let you know if I face any difficulties.
Hello Sir,
It still doesn't take up the second value.
The original OIR I created was,
(Single attribute)
<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator" ignore="false" force="false" final="false">
<Value algorithm="wt.rule.algorithm.CaseBranch">
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="Customer"/>
<Arg>******</Arg>
</Value>
<Arg>001</Arg>
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="Customer"/>
<Arg>******</Arg>
</Value>
<Arg>002</Arg>
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="Customer"/>
<Arg>******</Arg>
</Value>
<Arg>003</Arg>
<Value algorithm="wt.rule.algorithm.StringEqualsTest">
<Attr id="Customer"/>
<Arg>*****</Arg>
</Value>
<!-- ***** is the customer name-->
</Value>
<Arg>{GEN:wt.enterprise.SequenceGenerator:test:3:0}</Arg>
</AttrValue>
The above OIR works for single attribute alone.
When I try to concatenate two attributes, it still takes up the first attribute and doesn't take the value of second one.
Greetings,
What I did for my particular application was create a definition variable concatenating the desirable attributes. The code snipped is as follows:
<AttributeValues obType="wt.doc.WTDocument">
<VarDef id="generatedNumber" algorithm=ext.xxxxxxxx.doc.DocNumberGenerator"> (xxxxxx can be your unique identified; name etc.; this generates a sequential unique identifier)
<Attr id="Attribute1'/>
<Attr id="Attribute2'/>
<Attr id="Attribute3'/>
<Arg>-</Arg> (if you want to separate the concatenated attributes with a hyphen)
</VarDef>
<AttrValue id="number">
<VarRef id="generatedNumber"/>
</AttrValue>
{Basically, the above snippet concatenates all your attributes and stores them in the variable 'generatedNumber', then recalls the value and places it in 'number' holder in Windchill.} - [For example; this would result in "Attribute1-Attribute2-Attribute3-001]
Hope this helps!
Cheers
Jas Virdee