
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 02:56 PM
We have an integration pulling CIs from the cmdb_ci table and need the class name rather than the actual table which is returned when you get the value for the cmdb_ci.sys_class_name field.
Curious how to pull the class name (not table name) through a REST call.
getClassDisplayValue() method is used when scripting inside SNOW itself, but I can't seem to find out how to get that result through the API.
Thanks!
Solved! Go to Solution.
- Labels:
-
Integrations
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 06:43 PM
You can add "sysparm_display_value=all" to your URL. Here is an example
Script
#!/bin/bash instance=******** username=******** password=******** sysid=a22be6f1dbfde7007c7e54f948961944 fieldnames=sys_id,name,manufacturer,sys_class_name base="https://$instance.service-now.com/api/now/table/cmdb_ci/$sysid" parms="sysparm_fields=$fieldnames&sysparm_display_value=all" url="$base?$parms" curl $url --request GET --user "$username:$password"
Output
{ "result": { "sys_id": { "display_value": "a22be6f1dbfde7007c7e54f948961944", "value": "a22be6f1dbfde7007c7e54f948961944" }, "name": { "display_value": "b24-rtr-2", "value": "b24-rtr-2" }, "sys_class_name": { "display_value": "IP Router", "value": "cmdb_ci_ip_router" }, "manufacturer": { "display_value": "Cisco", "link": "https://********.service-now.com/api/now/table/core_company/fc8318026fc8de002cc8186e6b3ee4ce", "value": "fc8318026fc8de002cc8186e6b3ee4ce" } } }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-16-2020 06:43 PM
You can add "sysparm_display_value=all" to your URL. Here is an example
Script
#!/bin/bash instance=******** username=******** password=******** sysid=a22be6f1dbfde7007c7e54f948961944 fieldnames=sys_id,name,manufacturer,sys_class_name base="https://$instance.service-now.com/api/now/table/cmdb_ci/$sysid" parms="sysparm_fields=$fieldnames&sysparm_display_value=all" url="$base?$parms" curl $url --request GET --user "$username:$password"
Output
{ "result": { "sys_id": { "display_value": "a22be6f1dbfde7007c7e54f948961944", "value": "a22be6f1dbfde7007c7e54f948961944" }, "name": { "display_value": "b24-rtr-2", "value": "b24-rtr-2" }, "sys_class_name": { "display_value": "IP Router", "value": "cmdb_ci_ip_router" }, "manufacturer": { "display_value": "Cisco", "link": "https://********.service-now.com/api/now/table/core_company/fc8318026fc8de002cc8186e6b3ee4ce", "value": "fc8318026fc8de002cc8186e6b3ee4ce" } } }

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2020 05:14 AM
Simple things. Thanks a ton for the feedback.
Have a great weekend!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2022 06:34 AM
How would this look in a perl script using Your ServiceNow::SOAP?
I cant seem to get anything back unless I use the specific server type.
Here is my current code.
print "CI_ITEM:$ci_item\n";
my $tablename = "cmdb_ci";
my $table = $connect->table($tablename);
my $fieldnames="sys_id,name,manufacturer,sys_class_name";
my $rec = $table->getRecords(sys_id => $ci_item, __encoded_query => "sysparm_view=standard_change");
#my $rec = $table->getRecords(sys_id => $ci_item, __encoded_query => "sysparm_fields=$fieldnames&sysparm_display_value=all");
print Dumper(@rec);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2022 03:46 PM
my $table = $connect->table('cmdb_ci');
my $rec = $table->setDV('all')->getRecord($ci_item);
print Dumper($rec);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2022 05:34 AM
Thanks for this example.
Just to be complete - there is another parameter available which controls if the JSON tag "link" appears into the result or not:
sysparm_exclude_reference_link = true
Note that this is a) an exclusion and b) depends on "sysparm_display_value" (= "all").
If you set them to "true", "link" will never be provided, default: "false" (as by the given example)