- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2025 12:44 AM
Good afternoon.
I have a Catalog Form, where new users details will be entered. Then a Scheduled Job runs in the background and submits.
The requirement is: this form should only create RITM/REQTASK for new users. But what is happening is, if the existing user is given, then also it is creating RITM but not REQTASK. A workflow is also running in the background.
Example: Assume a person's profile got created (sys_created_on) in 2016 and his start date (u_start_date) is 2024 will be mentioned on his sys_user profile. But the point is, he is an existing user, but then too, for him, if we submit the form, RITM is getting created. Please check the below code and help me out.
The script is below:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2025 06:25 AM
try this
answer = ifScript();
function ifScript() {
var date;
var user = '105d95b80f3f52007b3a3e7ce1050edc';
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", user);
gr.query();
if (gr.next()) {
date = gr.sys_created_on;
gs.info("User " + gr.name + " User creation date " + date);
}
var nowTime = new GlideDateTime(date).getDate();
var dateField = new GlideDateTime('2025-03-11 11:11:03').getDate();
var c_date = new GlideDate();
var dur1 = GlideDate.subtract(nowTime, c_date).getDayPart();
if (dur1 == 0) {
gs.info("Start Date of field " + dateField);
gs.info("Creation date trimming time " + nowTime);
var dur = GlideDateTime.subtract(nowTime, dateField);
var days = dur.getDayPart();
gs.info("Real time " + days);
if (days >= -3 && days <= 28) {
return 'yes';
}
}
return 'no';
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2025 06:25 AM
try this
answer = ifScript();
function ifScript() {
var date;
var user = '105d95b80f3f52007b3a3e7ce1050edc';
var gr = new GlideRecord("sys_user");
gr.addQuery("sys_id", user);
gr.query();
if (gr.next()) {
date = gr.sys_created_on;
gs.info("User " + gr.name + " User creation date " + date);
}
var nowTime = new GlideDateTime(date).getDate();
var dateField = new GlideDateTime('2025-03-11 11:11:03').getDate();
var c_date = new GlideDate();
var dur1 = GlideDate.subtract(nowTime, c_date).getDayPart();
if (dur1 == 0) {
gs.info("Start Date of field " + dateField);
gs.info("Creation date trimming time " + nowTime);
var dur = GlideDateTime.subtract(nowTime, dateField);
var days = dur.getDayPart();
gs.info("Real time " + days);
if (days >= -3 && days <= 28) {
return 'yes';
}
}
return 'no';
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2025 03:10 AM
Hi,
So you have a Catalog item that gets submitted, and a scheduled job that runs regularly, and submits another Catalog item based on some conditions from this first catalog item. Why?
Seems unnecessary complex. Why not do all the logic in the first Catalog item directly ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-11-2025 04:44 AM
Hi OlaN. I found a similar condition in worklfow script. The code is below. Please check, why for existing users, it is creating RITM/REQTASK.