- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:26 PM
Hi Team,
I am trying to fetch the record and I want it dynamically, so whenever I am selecting the record in instance 2, I want all the data of that record from instance 1.
I am using rest message for this and in get method I am trying to fetch the single record.
I am able to fetch all the records but I want single record only.
any changes I need to do in script?
I am able to pass the query parameters but not able to see them in the script?
try { var r = new sn_ws.RESTMessageV2('PDI Int Get data', 'Default GET'); //override authentication profile //authentication type ='basic'/ 'oauth2' //r.setAuthenticationProfile(authentication type, profile name); //set a MID server name if one wants to run the message on MID //r.setMIDServer('MY_MID_SERVER'); //if the message is configured to communicate through ECC queue, either //by setting a MID server or calling executeAsync, one needs to set skip_sensor //to true. Otherwise, one may get an intermittent error that the response body is null //r.setEccParameter('skip_sensor', true); var response = r.execute(); var responseBody = response.getBody(); var httpStatus = response.getStatusCode(); } catch(ex) { var message = ex.message; }
Can anyone help me in this?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:39 PM
you need to use Retrieve records API and pass the query
Use this to get only 1 record
You will also get code sample on how to consume it. this will help you when you consume it from other instance
No need of REST Message in other instance, directly use the above script and give correct authentication details.
I believe this much information is sufficient for you to start and enhance it further
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:50 PM
To fetch single record from other instance, we have make our endpoint unique, make modification in REST Message with the GET method with following endpoint.
https://instance1.service-now.com/api/now/table/{table_name}/{sys_id}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2025 02:37 AM
Hi tried applying query but still it is fetching all record,
following is the script
@Community Alums @Lhora Alvarez
can you check
Calling this script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2025 10:56 PM
I am able to pass the query parameters but not able to see them in the script?
You need to define the values you pass as variables, which is why they aren't showing in the script.
Variables should be in the format ${variable_name}.
After entering the variables in the endpoint or parameters, click "Auto-generate variables" in the related links.
This will generate and display the variable records in the Variable Substitutions related list.
Please refer to this documentation: https://www.servicenow.com/docs/bundle/yokohama-api-reference/page/integrate/outbound-rest/concept/c...