Catalog date variables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 09:24 AM
How to add +7 days to the catalog variable based on RITM created date
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 09:38 AM
Please see below:
var gd = new GlideDate();
gd.addDays(7);
current.sys_created_on = gd;
var gdt = new GlideDateTime();
gdt.addDays(7);
current.due_date = gdt;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 09:58 AM - edited ‎05-08-2025 10:00 AM
Hello,
You can set its Default value to this:
javascript:gs.daysAgo(-7);
Important: replace the : part with an actual colon : character as shown in the screen shot:
Result:
Regards,
Robert
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-08-2025 10:09 AM
To add +7 days to a catalog variable based on the RITM (Requested Item) created date, you'll typically use a Catalog Client Script and GlideAjax with a Script Include.
Script Include:
var RITMHelper = Class.create();
RITMHelper.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getDueDatePlus7: function() {
var gr = new GlideRecord('sc_req_item');
if (gr.get(this.getParameter('sysparm_ritm'))) {
var gdt = new GlideDateTime(gr.sys_created_on);
gdt.addDays(7); // server-side method
return gdt.getDate().toString(); // return only date part
}
return '';
}
});
Client script:
function onLoad() {
var ga = new GlideAjax('RITMHelper');
ga.addParam('sysparm_name', 'getDueDatePlus7');
ga.addParam('sysparm_ritm', g_form.getUniqueValue());
ga.getXMLAnswer(function(response) {
if (response) {
g_form.setValue('u_due_date', response); // reaplace 'u_due_date' with actual variable name
}
});
}
Hope this helps!
"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"
Thank You
Juhi Poddar