How to add current time + extra time on ATF script
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 07:57 AM
Hey Developer,
I need to write a script to add 3minutes to current time & set these values on Planned state date on change request form.
Ex:- current time + 3minutes & then set this value to Planned start date on change record via ATF script.
Please suggest.
Thank you
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2023 10:11 AM
you can use ServiceNow's GlideDateTime API to achieve this. Here's an example script to add 3 minutes to the current time and set the result to the "Planned start date" field on a change request form:
// Get the current time var currentTime = new GlideDateTime(); // Add 3 minutes currentTime.addMinutes(3); // Set the value on the Planned start date field var changeRequest = new GlideRecord('change_request'); changeRequest.addQuery('sys_id', current.sys_id); // Replace current with the sys_id of the current change request changeRequest.query(); if (changeRequest.next()) { changeRequest.setValue('start_date', currentTime); changeRequest.update(); }