Auto Increment Numerical Value in Catalog Item Variable "Project number"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 04:59 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-13-2022 11:56 PM
Hey,
Did you get a chance to implement the solution?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-31-2022 03:20 AM
Hi
Sorry for the late reply,
I have created business rule for getting the Auto number.
Table : RITM
Conditions: Before - insert - Item is XYZ
Script:
(function executeRule(current, previous /*null when async*/ ) {
var reqItemGr = new GlideRecord('sc_item_option');
reqItemGr.addEncodedQuery('item_option_new.question_textSTARTSWITHproject number');
reqItemGr.orderByDesc('value');
//reqItemGr.orderByDesc('created');
reqItemGr.setLimit(1);
//reqItemGr.orderBy('value');
reqItemGr.query();
if (reqItemGr.next()) {
//var number = parseInt(reqItemGr.value);
var number = reqItemGr.value;
if (current.variables.request_type == 'original') {
number++;
} else if (current.variables.request_type == 'part_2') {
number = parseInt(current.variables.project_number) + 0.2;
} else {
number = parseInt(current.variables.project_number) + 0.3;
}
}
current.variables.project_number = number.toString();
})(current, previous);
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-30-2022 02:10 AM
Hi Ankur,
Can you please advice me here
I want to Auto increment the variable in the MRV's and i need this to achieve one of my requirement below
https://community.servicenow.com/community?id=community_question&sys_id=f9fcfeaddba68150e2adc22305961951
Please suggest me how to add the variable inside the MRV's for the auto increment ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2024 05:47 AM
Hi Ankur,
I tried to implement this but I am getting value like this INC2.0, INC3.0 ......... like this instead of INC00001, INC00002 do you have any idea why I am getting this ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2024 03:21 AM
Hi Prasad, are you able to implement this ?