cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

How add a prefix to an autogenerated number?

VladiSlav
17-Peridot

How add a prefix to an autogenerated number?

Hello everyone, can you please tell me how can I add a prefix to an autogenerated number?

How to get this number: ABC.000_018_5268?
<AttributeValues objType="wt.part.WTPart">
	<AttrConstraint id="number" algorithm="com.ptc.core.rule.server.impl.GatherAttributeConstraints">  	         
		<Value algorithm="com.ptc.core.rule.server.impl.GetServerAssignedConstraint"/>      
	</AttrConstraint>        
</AttributeValues>
4 REPLIES 4
BenLoosli
23-Emerald II
(To:VladiSlav)

<!--
  set the number to a generated number 
  -->
- <AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
  <Arg><YOUR PREFIX VALUE HERE></Arg>
  <Arg>{GEN:wt.enterprise.SequenceGenerator:PROMOTIONNOTICEID_seq:7:0}</Arg>
  </AttrValue>
 
Replace the <YOUR PREFIX VALUE HERE> with whatever you need for the prefix value.
 
Getting your desired string maybe a little difficult. 
What is the fixed portion of your string? Just the 'ABC.'?
How is the rest of your number being generated? I don't think the database sequence generator will create this number '000_018_5268'.
If you drop the underscores, then it should be able to give you '0000185268'. There are CS articles on how to set the sequence generator to predefined start number, see CS153590 for starters.
 
If your numbers must be consecutive, there are other things that need to be done.
The sequencing will jump numbers if idle for too long. It is a DB setting to not jump numbers, but I don't have that CS article handy to reference.
There is also an issue with save-as in Windchill in that when you do the save-as, the system pulls a new number for all of the files in your assembly and then throws away those numbers that are not being given new names, creating a gap in your sequencing.

   ,thank you very much for the quick response. I added your code, but now the number is no generated automatically

 

<AttributeValues objType="wt.part.WTPart">
	<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
		<Arg>ABC</Arg>
		<Arg>{GEN:wt.enterprise.SequenceGenerator:PROMOTIONNOTICEID_seq:7:0}</Arg>
	</AttrValue>       
</AttributeValues>

 

 

img.PNG

BenLoosli
23-Emerald II
(To:VladiSlav)

Sorry, that was for a promotion request, not a new part. Here is the code for a new part.

 

<!--
 set the number to a generated number 
  -->
- <AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
 - <Value algorithm="wt.rule.algorithm.BooleanBranch">
  <Arg><YOUR PREFIX HERE></Arg>
<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
  </AttrValue>
 
Try that instead.

 

, nothing has changed

 

 

<AttributeValues objType="wt.part.WTPart">
	<AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
		<Value algorithm="wt.rule.algorithm.BooleanBranch">
			<Arg>PREFIX</Arg>
			<Arg>{GEN:wt.enterprise.SequenceGenerator:WTPARTID_seq:10:0}</Arg>
		</Value>
	</AttrValue>     
</AttributeValues>

 

 

Announcements


Top Tags