Make a new field auto numbered

sayalimore
Kilo Expert

Is it possible to have two fields in one table be auto numbered?

On Incident table, there is a number field which is auto numbered already.

Now I have created one more field (on same table)which also needs to be auto numbered on every update happened on the incident form.

Any help will be appreciated 🙂

15 REPLIES 15

e.g When incident is created, MessageNumber =1. If any update happened on that incident, then MessageNumber =2.


Another incident is created, then MessageNumber =3 like that.


So after 2nd incident is created you would like to set MessageNumber   to 3 that is fine. SO what if someone updates the 1st incident?


Would you like to overwrite MessageNumber value from 2 to 4?



If that is the case you will never know where you started and in my opinion the MessageNumber   value will not provide you any helpful metric.



Can you tell us business case?


find_real_file.png


Yes this is the same case I want to implement.


for every update/insert the message number will increase by 1.


If previous message number is 5, then for next update on any incident the message number should be 6.


Write a before insert, update business rule and udpate the script provided by @sharique




var gr= new GlideRecord('incident'); //say my table is incident..


gr.orderByDesc('u_messagenumber');


gr.setLimit(1)


gr.query();


if(gr.next()){



var str_i = parseInt(gr.u_messagenumber);


str_i++;


current.u_messagenumber = str_i



}


Michael Ritchie
ServiceNow Employee
ServiceNow Employee

Sayali, are you trying to determine how many updates are occurring on a task?   If so, there is an out of the box field on task called Updates (sys_mod_count) that increments on every update.


Hi Michael,


I dont want to record an updates. I have replied above with my full requirement.