- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-10-2023 11:20 PM
My requirement is I need to get all the active incidents from Instance A and Store those values in the custom table of instances B.
*Custom table has 4 fields (u_number, u_inc_short_descriptio, u_inc_description, u_inc_channel) I have to set these field values to the response from instance A get method.
*Please suggest to me how I can achieve this using scripted rest api.
with ServiceNow instance A and ServiceNow instance B
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 12:29 AM
Why not? There we go.
sm.setEndpoint('<instance_name>/api/now/table/incident');
sm.setHttpMethod('GET');
sm.setQueryParameter("sysparm_query","active=true");
sm.setQueryParameter("sysparm_fields","number,short_description,description,contact_type");
var response = sm.execute();
var responseBody = response.getBody(); //this is return an object contains result array of incidents
So from the Instance B, we can leverage the method GET to pull the data from the Instance A.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 12:36 AM - edited ‎10-11-2023 12:38 AM
Not at all. Just use the OOTB ones for your case.
You can also play with other APIs within the REST API Explorer in ServiceNow.
URL: https://<instance_name>/$restapi.do
The one from my comments is Table API.
ServiceNow Developer Table API Reference
Cheers,
Tai Vu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 12:13 AM
Can we use the script include in Instance B to set Values in the custom table by calling get method from Instance A ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2023 12:29 AM
Why not? There we go.
sm.setEndpoint('<instance_name>/api/now/table/incident');
sm.setHttpMethod('GET');
sm.setQueryParameter("sysparm_query","active=true");
sm.setQueryParameter("sysparm_fields","number,short_description,description,contact_type");
var response = sm.execute();
var responseBody = response.getBody(); //this is return an object contains result array of incidents
So from the Instance B, we can leverage the method GET to pull the data from the Instance A.