How to add dynamic condition in Business Rule for records updated 6 days ago ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 11:51 PM
Hi Community,
Please find my requirement below:
I need to change the status of legal Request which is in Awaiting User Info state and last updated 6 days ago to "Resolved" and trigger a notification for Requestor.
I created a after Update BR for this. However, I cannot add the dynamic condition in BR that record must be updated 6 days ago.
Could you pleaseee help me here ?
Do I need to write a query in Condition field of BR or write a method in script ?
Thanks in Advance,
Hritik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 11:58 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-04-2024 11:59 PM
Hi @Hritik,
please check below script:
// Check if state is "Awaiting User Info" and last updated 6 days ago
if (current.state == 'Awaiting User Info') {
var updatedDate = new GlideDateTime(current.sys_updated_on);
var sixDaysAgo = gs.daysAgoStart(6);
if (updatedDate < sixDaysAgo) {
// Perform actions (e.g., change state to "Resolved" and trigger notification)
current.state = 'Resolved';
current.update();
// Trigger notification to the requestor
// Example: gs.eventQueue('my.notification.event', current, current.requested_for);
}
}
Thank you, please make helpful if you accept the solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 09:44 PM
Could you please let me know How do I register an event for the notification ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2024 09:54 PM
Hi @Hritik
refer this:
https://docs.servicenow.com/bundle/washingtondc-mobile/page/administer/tablet-mobile-ui/task/configu...
https://docs.servicenow.com/bundle/washingtondc-build-workflows/page/administer/platform-events/task...
……………………………………………………………………………………………………
Please Mark it helpful 👍and Accept Solution✔️!! If this helps you to understand.