- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 06:56 AM
Hi Team,
I assume this is pretty straight forward to configure via a Business Rule, also would it be an Insert/Update Business Rule?
What would be required to configure a simple Business Rule, that auto-closes any Interaction, after one hour (60 mins) of that Interaction having been opened, provided the Interaction has not been Updated within that hour.
Many thanks for the guidance/advice.
I am looking to configure this on my PDI.
Kind Regard, Warwick
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 09:42 AM
I don't think a Business Rule would work here as it would need to run on an update of a record, and your use case is actually about lack of updates 🙂
So I would suggest creating a scheduled job instead (sysauto_script):
Set it to Run: Periodically, let's say every 10 minutes ( I would advise against running it too frequently).
Set the script to something like this:
var closeInterval = '60'; // in minutes <-- replace this hard coded value with a system property!
function abandonedIntractions(time) {
var interactionToClose = new GlideRecord('interaction');
interactionToClose.addEncodedQuery('active=true^sys_updated_onRELATIVELT@minute@ago@' + time);
interactionToClose.setValue('state', 5); // 5 = Close abandoned
interactionToClose.updateMultiple();
}
abandonedIntractions(closeInterval);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 03:10 PM - edited 05-15-2023 03:13 PM
Hi,
You can add "^interaction_type='Phone'" to the query Laszlo provided, like:
interactionToClose.addEncodedQuery('active=true^sys_updated_onRELATIVELT@minute@ago@' + time + '^interaction_type=Phone');
You must use the field name and value for "Interaction Type = Phone". If the Interaction Type field is a choice field, then the value for "Phone" would be needed in the query.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 09:58 AM
HI @WazzaJC ,
I trust you are doing great.
Go to the ServiceNow instance where you want to configure the Business Rule.
Navigate to the "Business Rules" module by searching for "Business Rules" in the navigation bar.
Click on "New" to create a new Business Rule.
Give your Business Rule a name, such as "Auto-Close Interaction after One Hour".
Set the "Table" field to "Interaction" to target the Interaction table.
In the "When to run" section, select "Before" and "Insert" operations to trigger the rule when a new Interaction record is created.
In the "Advanced" section, click on the "Add condition" button to add a condition for the rule to check if the Interaction hasn't been updated within one hour.
Set the condition to check if the "sys_updated_on" field (which represents the last updated time) is less than the current time minus 60 minutes.
Example condition code: current.sys_updated_on < gs.minutesAgo(60)
In the "Advanced" section, add an action to close the Interaction record. You can use the current variable to refer to the current record being processed by the rule.
Example action code: current.state = 6; (assuming the state field represents the status of the Interaction record and 6 represents the "Closed" state)
Save the Business Rule.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2023 11:47 PM
Many thanks Amit.