Two number maintenance for one single table/form in servicenow.

VikramM1
Tera Contributor

Is there any possibility to create two number maintenance auto numbering for a single table or  form.

 

I created one number maintenance like DNC-00001, I want this create one more like D-0001.

 

If not possible with number main any other suggestions or code that any one can share that will be helpful.

3 REPLIES 3

johnfeist
Mega Sage
Mega Sage

Hi VIkramM1,

 

If the new number is simply an extraction from the existing one, you can add that field onto your record and then create a before insert business rule.  In it you just need a statement something like this:

current.otherNumber = <prefix> + current.number.substring(x,y);

where <prefix is D- or whatever and x,y are start and length.

Make sure that you don't include an update() statement in any before insert rule or you could end up in an endless loop.

 

If you need to use some other sequential mechanism, the simplest thing is to create a property and start it with zero.  Then your before insert rule can look up the value, increment it for attaching to the alternative number field and also update the property.

Hope that helps.

:{)

Helpful and Correct tags are appreciated and help others to find information faster

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @VikramM1 

 

Any reason to have 2 different numbers for the same form? It is not  a recommended approach.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Sohail Khilji
Kilo Patron
Kilo Patron

Hi @VikramM1 ,

 

Yes ! but techenically not good unless you can manage it well ! 

 

The way to do is by creating 2 diffrent numbering field on 1 table with Prex as DNC-00001 and D-0001 instead of 1 field. (the possible solution is by using 2 field not by 1 field)

 

Based on your conditon you can set the UI POLICY visiblity of each field. I hope this helps...


☑️ Please mark responses as HELPFUL or ACCEPT SOLUTION to assist future users in finding the right solution....

LinkedIn - Lets Connect