How to increment numbers in a variable field in a request item?

Debbi L
Tera Expert

I think I may be making this more complicated than I should, so I'm throwing this out to the experts.

I have a request item that contains several variables that feed into a series of approvals. The first variable question is a string that we've called "IT Change Control Number." The business group who controls the workflow would like, instead of trying to maintain a separate list of available numbers, for the form to create an autofilled, generated number that is sequential and uninterrupted (for audit purposes). Which means that I can't set this up to auto-populate when the record is opened, because if the user abandons the request, that number will disappear. I want to fill the field on submit, which doesn't sound like it should be too difficult. I've created a table for it to pull from, containing the prefix (as a 3 character string, this will remain the same), the current year, and then the integer field, which we'll increment for each submitted request. The end result will appear thus: XXX2017-1001. And...I'm not sure where to go from here. I'm a scripting neophyte, if that tells you anything. Thank you in advance!!!

1 ACCEPTED SOLUTION

Mukesh Sharma
Giga Expert

Well I do not see a need to create a new table for this . but since you have created a table . and your first two things you are picking from that table (static string and year ) you can also create the third field to store the number. and after that



1. create on submit client script .


2. call an script include from on submit client script .


3. write a code in script include to get all three values from table and while retrieving the values . increment the third field value and save the record (so everytime when you create the request . you will pick the last field value and increment it by one and save it back ).


4, make your string with combining all 3 values and and return it to onSubmit client script .



Kindly let me know if I got your requirement correctly . There are other ways as well to do this requirement . which wont require any table.




Kindly mark helpful if it helps.


View solution in original post

8 REPLIES 8

Mukesh Sharma
Giga Expert

Well I do not see a need to create a new table for this . but since you have created a table . and your first two things you are picking from that table (static string and year ) you can also create the third field to store the number. and after that



1. create on submit client script .


2. call an script include from on submit client script .


3. write a code in script include to get all three values from table and while retrieving the values . increment the third field value and save the record (so everytime when you create the request . you will pick the last field value and increment it by one and save it back ).


4, make your string with combining all 3 values and and return it to onSubmit client script .



Kindly let me know if I got your requirement correctly . There are other ways as well to do this requirement . which wont require any table.




Kindly mark helpful if it helps.


Thank you, I'll give this a shot.


kmrs
Kilo Contributor

Hi Debbil,

Could you please share your script, currently me  also working on same requirement.

Thanks in advance.. 

Did this work for you??  If so, can you provide the script(s)??

Thanks.