- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 04:08 AM
Hi,
I'm trying to fetch data from another dev instance. My question is how to fetch display name model and model category (both are reference field) in asset table. Model and model category remains blank. Both sys_id's between stances are different so I guess I have to use displayed name.
I tried getDisplayName() but it doesn't work.
try {
var r = new sn_ws.RESTMessageV2('REST API tests', 'Get Assets');
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
var parsedData = JSON.parse(responseBody);
for (i = 0; i < parsedData.result.length; i++) {
var assets = new GlideRecord('alm_asset');
assets.initialize();
assets.display_name = parsedData.result[i].display_name;
assets.model = parsedData.result[i].model;
assets.model_category = parsedData.result[i].model_category;
assets.asset_tag = parsedData.result[i].asset_tag;
assets.insert();
}
} catch (ex) {
var message = ex.message;
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 05:15 AM - edited 10-27-2022 05:16 AM
Hi,
You are using table API and to get display value in response you need too update your links like below:
https://devxxxxx.service-now.com/api/now/table/cmdb_model_category/c9d5bc50c3031000b959fd251eba8fbc?sysparm_display_value=all
and
https://devxxxxx.service-now.com/api/now/table/cmdb_model/12345bc50c3031000b959fd251eba8fbc?sysparm_display_value=all
Add additional query parameter:
sysparm_display_value=all
Thanks
Anil Lande

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 04:56 AM
Hi,
Have you tried printing response object? Are you receiving display Value from API?
If you are receiving only sys_id then you need to change Scripted Rest API defination in another instance and return display value instead of sys_id (or return both values). Then you can get that value in your current instance.
Can you please share which API you are using to get data? OOB or custom?
Thanks
Anil Lande
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 05:07 AM - edited 10-27-2022 05:07 AM
model and model category are represented in Json as a link and sysid
I'm using REST message to fetch data between two my pdi's
"model_category": {
"link": "https://dev*****service-now.com/api/now/table/cmdb_model_category/81feb9c137101000deeabfc8bcbe5dc4",
"value": "81feb9c137101000deeabfc8bcbe5dc4"
"model": {
"link": "https://dev*****.service-now.com/api/now/table/cmdb_model/f8fa15df0a0a0b9100a14bd778fb212a",
"value": "f8fa15df0a0a0b9100a14bd778fb212a"
},

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 05:15 AM - edited 10-27-2022 05:16 AM
Hi,
You are using table API and to get display value in response you need too update your links like below:
https://devxxxxx.service-now.com/api/now/table/cmdb_model_category/c9d5bc50c3031000b959fd251eba8fbc?sysparm_display_value=all
and
https://devxxxxx.service-now.com/api/now/table/cmdb_model/12345bc50c3031000b959fd251eba8fbc?sysparm_display_value=all
Add additional query parameter:
sysparm_display_value=all
Thanks
Anil Lande