Search code examples
httpsservicenow

How do I combine multiple sys_class_name while query?


In the path below where I am doing filter on sys_class_name = Generic Application

/api/now/table/cmdb_ci?&sysparm_display_value=true&sysparm_exclude_reference_link=true&sys_class_name=Generic Application

I have multiple sys_class_name like Application, Generic Application, ServiceNow Application, Share point, IBM Websphere, Business application, business service, discovered service, web application, web service, web site.

My question is how do I combine all these Sys_Class_Names?


Solution

  • You actually want to use the sysparm_query URL parameter with an IN condition: sysparm_query=sys_class_nameINcmdb_ci_appl,cmdb_ci_appl_generic,...

    The whole URL looks something like this: /api/now/table/cmdb_ci?sysparm_query=sys_class_nameINcmdb_ci_appl%2Ccmdb_ci_appl_generic

    Note: this is using the actual class name (e.g. cmdb_ci_appl_generic) in place of the class _label_. If you need to look up the name based on the label, go to /sys_db_object_list.do.

    One easy way to use sysparm_query is to just build the list you want in the UI using the normal filter, and then just right-click the breadcrumbs (the blue text above the filter after Running) for the filter, and click Copy Query. That can just be pasted in as the sysparm_query in the table API.