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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Autogenerated numbers skiiping few numbers while creating new objctct and increments also on error.

@_1647
10-Marble

Autogenerated numbers skiiping few numbers while creating new objctct and increments also on error.

Hi everyone ,

I have custom form processor that create new WTPart from create wizard of  Document and number of part is same as document , so i have custom numbering schema in my customised OIR that gives me  editable generated number on wizard but problem is in preProcess() method it skips the few number while creating new Part which i don't want part number should be same as document number and one more condition is if i edit the number filed and the wrong numbers then i handeld the exception which helps me to do not create document but in this case in backend it autogenerates the number and increments that on error also which shoul be prevented ,
So how can we prevent the skiiping of number and increamenting of number on error using java code

7 REPLIES 7
avillanueva
22-Sapphire II
(To:@_1647)

Is this using an Oracle sequence?  If so, this is a common problem. A quick google search can yield a ton of articles on this:

https://asktom.oracle.com/ords/asktom.search?tag=sequence-behavior-skipping-values

https://www.ptc.com/en/support/article/CS198446?source=search

I ditched sequences for my CN numbers and opted for a search for latest number and add one. This seems to work in my case. 

@avillanueva 

Agreed. I've done the same thing for companies that wanted the CA number the same as the CO number.  And yes, they restricted the number of CAs on a CO to 1. 😁

 

I'm with you, bag the sequence and write one's own logic to determine the number.

 

BTW, this post should really be in the customization board because, well, it is a customization. 😉

 

 

Hi avillanueva,

No that is not an oracle sequence I have just added the pre-fix and postfix only in OIR and kept the 8-digit number in the middle.

I have one API that gives me the generated number in preProcess() but that is incremented cause it takes the object as a new object and it increments the number --> String number = EnterpriseHelper.getNumber(); 
So Could you help me to sort this out and if you have an API that gives the latest sequence number for the current object then that would be highly appreciated.
avillanueva
22-Sapphire II
(To:@_1647)

But I still think that 8 digit number is coming from the an Oracle Sequence. That is what EnterpriseHelper is returning. Any call to get the next number from a sequence, whether it succeeds or fails will advance it. This is what I believe causes the gaps that you are seeing. Can you post your composite OIR?

@_1647
10-Marble
(To:@_1647)

 <!-- set the number to a Editable Generated Number field  -->
               <AttrValue id="number" algorithm="com.ptc.windchill.enterprise.revisionControlled.server.impl.NumberGenerator">
   <Arg>XXXxx</Arg>
                  <Arg>{GEN:wt.enterprise.SequenceGenerator:WTDOCUMENTID_seq:8:0}</Arg>
   <Arg>XXXXX</Arg>
               </AttrValue>
 
   <!-- AttrConstraint are -->
  
<AttrConstraint id="number" algorithm="com.ptc.core.rule.server.impl.GatherAttributeConstraints">
            <Value algorithm="com.ptc.core.rule.server.impl.GetServerAssignedConstraint"/> 
            <!-- <Value algorithm="com.ptc.core.rule.server.impl.GetImmutableConstraint"/>  -->
       </AttrConstraint>
avillanueva
22-Sapphire II
(To:@_1647)

Yep, there is your Oracle sequence WTDOCUMENTID_seq.

So now do we have any way to get current sequence number not next.

Top Tags