Rest call occurring twice during single update.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 02:38 AM
Hi all!
I am updating single record in a single time but the api is hitting twice.
Description :
I created import set row table u_abc for targeting incident table using "number" and "work_notes" field. The table u_xyz have u_id and u_work_notes. Whenever I update those two field, Before business rule will run and call rest message to insert record in u_abc and finally update the incident record via transform mapping.
Issue :
Now the issue is, execution happening twice during every single update. Two times inserting in import table u_abc, at the same time two times updating incident table also
This is my BR:
Table : u_xyz
When : Before Update
Order : 13,500
Script :
(function executeRule(current, previous /*null when async*/) {
// Add your code here
gs.log("rest details"+current.u_id + current.u_work_notes);
var request = new sn_ws.RESTMessageV2("ServiceNow sample", "update comments");
request.setStringParameterNoEscape("number", current.u_id);
request.setStringParameterNoEscape("notes", current.u_work_notes);
request.execute();
var response = request.execute();
var requestBody = request.getRequestBody();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log("response_incident" + httpStatus + responseBody );
})(current, previous);
This is my Rest message :
Using import API
{"u_number":"${number}","u_work_notes":"${notes}"}
Can anyone help?
Thanks in advance!
- Labels:
-
Integrations

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 02:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 04:28 AM
only update

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 04:56 AM
I see a comment in your Description "and finally update the incident record via transform mapping. " maybe can you not do this and see if system updates the record by backend only?
Thanks,
Saji
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2020 02:53 AM
Hi,
it is recommended to call the Rest Message in After or Async business rule and not in the before business rule
Please make the BR as After and test once
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader