- 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 05:41 AM
@Ankur Bawiskar ..Is there a way to achieve this ? Could you suggest something ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2023 07:06 AM
not possible in scheduled job.
you should use flow designer which runs every min and check the records matching the conditions.
you cannot compare exact seconds.
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 07:09 AM
@Ankur Bawiskar So, that means in flow designer also exact time cannot be compared ?
Then i think i should just compare on date value ?
- 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-21-2023 03:49 AM
@Ankur Bawiskar ...Doing this through workflow will be ok ?