- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 03:42 AM - edited ‎03-20-2023 03:43 AM
To change state value to Open when custom date/time field (Reactivation Time) value matches with system date/time.
I am trying with below code, which is not giving the output.
Is there anything i am missing here ? Kindly Suggest
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('state=30^u_reactivation_timeISNOTEMPTY');
gr.query();
while (gr.next()) {
var reopen_date = new GlideDateTime(gr.u_reactivation_time);
var today_date = GlideDateTime();
if (reopen_date == today_date) {
gr.state = '10';
gr.work_notes = 'Updated State to Reopen';
gr.update();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 07:11 AM
if you are ok with Date then use scheduled job script.
If you are ok with minutes without thinking about seconds value then use flow designer.
But running flow every minute will lead to performance issue.
Please discuss with your customer about this.
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-20-2023 03:45 AM
if you are saying dates should be same then do this
var gr = new GlideRecord('sn_hr_core_case');
gr.addEncodedQuery('state=30^u_reactivation_timeISNOTEMPTY');
gr.query();
while (gr.next()) {
var reopen_date = new GlideDateTime(gr.u_reactivation_time);
var today_date = new GlideDateTime();
if (reopen_date.getDate() == today_date.getDate()) {
gr.state = '10';
gr.work_notes = 'Updated State to Reopen';
gr.update();
}
}
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-20-2023 03:58 AM - edited ‎03-20-2023 04:01 AM
@Ankur Bawiskar
No, Just for Dates ..i already got that working.
I have to reopen the ticket on the exact date & time selected in the custom date/time field.
How to match the time as well ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2023 04:07 AM
where have you written the above script?
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-20-2023 04:08 AM
@Ankur Bawiskar ..In Scheduled Jobs