Do Business Rules execute when a record is updated using REST Integration?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2017 01:32 PM
We have a business rule that sets the Resolved date field in the incident table when a incident record is updated to the state of Resolved. We also have an integration with a vendor where when an Incident is created in our SN environment, it will create an Incident in their non-SN ticketing system. This integration is bi-directional so that we get updates based on the work they are performing. However, when they set an Incident in our SN environement is resolved using the integration, the Resolved date field is not being set. My assumption is that Business Rules only execute when an action is performed in the UI and not through integration, but that is just a guess. Anyone have any thought/idea on this?
- Labels:
-
Integrations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-21-2017 06:31 AM
The Business Rule is called "mark_resolved" and appears to be an out-of-box rule. It has the following parameters and script.
- Parameters
- Table: Incident
- When: Before
- Insert and Update are both checked
- Script
-----------
setResolutionFields();
function setResolutionFields() {
if (current.resolved_by.nil())
current.resolved_by = gs.getUserID();
if (current.resolved_at.nil())
current.resolved_at = gs.nowDateTime();
// Update the fields that indicate the time and duration of this incident from open to resolve.
// Keep track of duration as a glide_duration value (dd hh:mm:ss) and as a pure number of seconds.
// Both calendar time and business time are maintained.
var dataChange = current.opened_at.changes() || current.resolved_at.changes();
var opened = current.opened_at.getDisplayValue();
var resolved = current.resolved_at.getDisplayValue();
if (dataChange || current.business_duration.nil())
current.business_duration = gs.calDateDiff(opened, resolved, false);
if (dataChange || current.business_stc.nil())
current.business_stc = gs.calDateDiff(opened, resolved, true);
if (dataChange || current.calendar_duration.nil())
current.calendar_duration = gs.dateDiff(opened, resolved, false);
if (dataChange || current.calendar_stc.nil())
current.calendar_stc = gs.dateDiff(opened, resolved, true);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2017 01:46 PM
Can you show us the Business Rule? Is it marked to run on "Update"? What is the code, if any, associated with it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2017 01:51 PM
NO. The Business rules run irrespective of how the record gets inserted besides some special cases where you have options to control like in transform maps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-20-2017 10:25 PM
Hi Jeromy,
in addition to some interesting suggestions already in this thread, I think you should take a close look at the when to run section of the BR you mention.
If solution is still not found, consider
Could there be other BR's involved? Perhaps on the task table?
Perhaps there are some custom fields with column or display names similar to OOB?
Are there any clues if you look at the history of the an incident when the Resolved date does get set compared with the history when the Resolved date does not get set.
If the reply was informational, please like, mark as helpful or mark as correct!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2017 03:57 PM
Jeromy,
We are glad you took advantage of the ServiceNow Community to learn more and to get your questions answered. The Customer Experience Team is working hard to ensure that the Community experience is most optimal for our customers.
If you feel that your question was answered, we would greatly appreciate if you could mark the appropriate thread as "Correct Answer". This allows other customers to learn from your thread and improves the ServiceNow Community experience.
If you are viewing this from the Community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Thanks,
Shivani Patel