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

Hi Dirk,

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.

Hi

Try this one:

https://developer.servicenow.com/connect.do#!/event/knowledge18/LAB0521/knowledge_18_LAB0521_ebondin...

ebonding should the one of the options of your choice (which uses Flow Designer and Integration Hub as Platfrom technology to integrate TWO ServiceNow Instances to exchange Incident data).

Let me know if that answers your question and mark my answer as correct/helpful, please.

BR

Dirk

Megha Padale
Giga Guru

Hi,

If the business rule is before insert or update BR, then system automatically does an update on the database when the script runs, and it doesn't need another current.update() in the script.

If my answer helped you, mark answer as helpful and correct.

Thanks and regards,

Megha.

 

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.