Is there any alternative for current.update() method in servicenow?

Pavan Kumar BV
Kilo Expert

Hello Everyone,

I have a business scenario where if i create an incident in InstanceA, it should create an incident in InstanceB. Also, any updates made to an incident in InstanceA should also reflect in InstanceB. I have configured a REST message and also a Business Rule. The problem is, i have used current.update() at the end of my BR and its causing performance issues while executing insert/update actions. Is there any alternative to this method to achieve back my performance?

Below is my BR

(function executeRule(current, previous) {

 var r = new sn_ws.RESTMessageV2('ABC to MSP Rest Message ', 'ABC to MSP');
 r.setStringParameterNoEscape('u_short_description', current.short_description);
 r.setStringParameterNoEscape('u_impact', current.impact);
 r.setStringParameterNoEscape('u_configuration_item', current.cmdb_ci);
 r.setStringParameterNoEscape('u_incnumber_abc', current.number);
 r.setStringParameterNoEscape('u_subcategory', current.subcategory);
 r.setStringParameterNoEscape('u_caller', current.caller_id);
 r.setStringParameterNoEscape('u_sysid_abc', current.sys_id);
 r.setStringParameterNoEscape('u_urgency', current.urgency);
 r.setStringParameterNoEscape('u_category', current.category);
 r.setStringParameterNoEscape('u_description', current.description);

 var response = r.execute();
 var responseBody = response.getBody();
 var parsed_response=JSON.parse(responseBody);
 var id =parsed_response.result[0].sys_id;
 var id1 =parsed_response.result[0].display_value;
 current.u_msp_incident_sysid = id;
 current.u_msp_incident_number = id1;
 current.update();
 var httpStatus = response.getStatusCode();

1 ACCEPTED SOLUTION

Pavan Kumar BV
Kilo Expert

I have figured out the problem for this unexpected behavior. It was in my HTTP method where i have given an extra space in one of the variable declaration. Once i rectified that everything is working as expected.

Thanks everyone for your response.

View solution in original post

13 REPLIES 13

Your previous code also had some current updates, where is this now? Or did you update your code? Is the updated code also performing better? If so, indeed: check the conditions of the Business Rule. I think it's just getting triggered over and over.

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

Hi there,

Still any help needed? Or did you manage with my responses?

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Mark
2020 ServiceNow Community MVP
2020 ServiceNow Developer MVP

---

LinkedIn
Community article list

 

Kind regards,

 

Mark Roethof

Independent ServiceNow Consultant

10x ServiceNow MVP

---

 

~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field

LinkedIn

DirkRedeker
Mega Sage
Hi I guess this live integration to update each record by business rule may block your system and slow it down. Have you tried to update asynchronously to get better system response? Let me know if that answered your question and mark my answer as correct and helpful BR Dirk

Hi Dirk,

Appreciate your response. I'm not sure about this process. If you have any good reference links on this topic, can you please share them here. Paralelly i will aslo check for some resources.

Hi

Can you share a screenshot of you BR?

Does it fire before or after?

Does is fire on insert and/or update?

What happens when you leave out the "current.update()"?

PLEASE, remember to try this only on non production instances.

Thanks for letting me know.

BR Dirk