How to reference multiple tables in one field using scripted reference qualifier?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-03-2016 10:43 PM
Happy New Year Folks!!
I want to be able to reference multiple tables in a field (named 'Target', reference type field) based on the value of another field (named 'Type').
For e.g.
when 'Type' = 'Service Offering', field 'Target' should reference 'service_offering' table;
when 'Type' = 'Configuration Item', field 'Target' should reference 'cmdb_ci' table etc.
How can this be achieved? Thanks for your help!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2016 05:07 PM
OOB Service Offering extends Business Service, which extends the CI table. CI is the base table of both,
Make your field a reference field of CI and your requirement is achievable.
You can add other exclusions to the [if true] section for your other tables.
//[Boolean condition ? [if true] : [if false];
//If you select a type of CMDB, it shows all CI's except service offerings
//If you select a type of Service Offing, it only shows SO's
javascript: (current.getValue('type')=='cmdb_ci') ? "sys_class_name!=service_offering":"sys_class_name!="current.getValue('type');
You could put the code above in a more readable "best practice" form in a script include if you wanted.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-20-2016 10:25 AM
Hi Simranjit,
From your requirements, it sounds like you would need to use a Document ID field type. It can reference any record in any table, and actually exists as two fields (one to store the table and the other the record sys_id).
Please see here in the wiki:
Creating a Document ID Field - ServiceNow Wiki
Hopefully that helps.
Thanks,
-Brian