form that that queries existing requests and then adds 1 to created unique id number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 11:34 AM
Hello,
If someone could point me the right direction, I would greatly appreciate it.
I am looking to recreate the set up I have in a form that uses php and a mysql database.
Prior to submitting, I have a query that counts the number of submitted request since the previous July 1 and then adds 1. This number, preceded by the calendar year, for example 24, is then submitted as a hidden field, becoming the request number.
So, if the query returns 122 submitted requests for this current year, 25, then the number for the hidden field would be 25.123
The form is in the process of being recreated in ServiceNow. Is there a chance I can replicate this in ServiceNow?
If so, that would be great. If someone could point me towards resources/documentation where I could learn and test this, I would be super grateful!
Thank you!
Peter T
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-10-2025 08:42 PM
@Peter Tattlebau
You can try to implement the below logic in before BR on your custom table for the field you want to populate this logic:
var gr = new GlideRecord("incident");
gr.query();
var count = gr.getRowCount(); //count = 70
count = count + 1;
var gdt = new GlideDateTime();
var year = gdt.getYear().toString(); //2025
year = year.substring(2, 4);
var finalStr = year + '.' + count;
gs.info(finalStr);
//25.71
Hope it helps 😉
Murthy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 05:57 AM
Thank you so much @Murthy Ch I will test this!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2025 02:21 PM