Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to set dynamic sys_id in PUT method end point in REST Integration

Community Alums
Not applicable

Need syntax for setting dynamic sys_id in End point for PUT method in REST Integration.   

If below is the URL https://instanceb.service-now.com/api/now/table/incident/${incident_id}       

then how to set value in incident_id. from Business Rule.

I have requirement to update record in Instance B if any record is updated in instance A. I have stored sys_id, number value of record from Instance B to Instance A so same number/sys_id i want to pass in end point URL of PUT method .

 

Need to know correct syntax for end point in that case and how to set value for the parameter

1 ACCEPTED SOLUTION

Mike Patel
Tera Sage

Can you share your business rule that kicks off the webservice. Basically you need to set parameter like 

r.setStringParameter('incident_id', current.XYZ); //XYZ is your field name

View solution in original post

6 REPLIES 6

Mike Patel
Tera Sage

Can you share your business rule that kicks off the webservice. Basically you need to set parameter like 

r.setStringParameter('incident_id', current.XYZ); //XYZ is your field name

Puvi
Kilo Contributor

Hi Mike,

    I would like to update incident record using PUT method through dynamic sysid. Please help me to get the result.

Keeping reference code for reference.

 

Capturing partner sysid in partner_id.

 

var partner_id = current.u_string_1;
      
    var request = new sn_ws.RESTMessageV2();
 // request.setStringParameter('https://dev52757.service-now.com/api/now/table/incident', current.u_string_1);
    request.setEndpoint('https://dev52757.service-now.com/api/now/table/incident/${partner_id}');

request.setHttpMethod('PUT');

 

Thank you

you need something like

var partner_id = current.u_string_1;
      
    var request = new sn_ws.RESTMessageV2();

  request.setEndpoint('https://dev52757.service-now.com/api/now/table/incident/' +partner_id);

request.setHttpMethod('PUT');

Inactive_Use407
Giga Contributor

@Puvi can you share the whole solution? For example, was this script created using a business rule in the incident table?