Advanced reference qualifier using script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 05:57 AM
Hello all,
I have a custom table - u_m2m_sys_user_cmdb_ci_service with 3 fields - User(sys_user), CI 1(u_cmdb_ci_service) and CI 2 (u_dev_prod_ci_secondary)
I need to create a variable on a catalog item to reference this table. However I need to query the table based on the logged in user and get to display the list to show up the value from 1 particular field from CI 1 (u_cmdb_ci_service.u_application_name)
I need help to achieve the same.
Below is the Script Include I am trying to build
var CRFNonUserShowappname = Class.create();
CRFNonUserShowappname.prototype = {
initialize: function() {
},
getCIIDs: function(a){
var usersList = [];
var user = gs.getUserID();
var gruser_list = new GlideRecord('u_m2m_sys_user_cmdb_ci_service');
gruser_list.addQuery('sys_user',user);
gruser_list.query();
var results = [];
while(gruser_list.next())
{
//usersList.push(gruser_list.getUniqueValue());
var list = gruser_list.getDisplayValue('u_cmdb_ci_service.u_application_name');
}
return list;
},
type: 'CRFNonUserShowappname'
};
@Ankur Bawiskar @Sandeep Rajput @AnveshKumar M @Peter Bodelier

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 06:03 AM - edited 10-26-2023 06:05 AM
Hi @DB1,
You can't manipulate the displayvalues in the field like this.
A reference qualifier needs to receive either a query, or a list of sys_id's in order to show anything.
You could show additional or other fields in the reference field, although I don't think you can show dotwalked values.
(Auto-complete for reference fields (servicenow.com) ref_ac_columns)
You may need to add a 4th field to the table to show the Application Name.
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 06:03 AM
simply do this in the advanced ref qualifier
javascript:'userField=' + gs.getUserID(); // give here the field which refers to user table
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
10-26-2023 07:38 AM
But I need the Application name that dot walked from CI 1 not just the records. How do I do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 11:34 AM
I think you want to show all the "application" based on the u_m2m_sys_user_cmdb_ci_service table right?
You have to reference the application table, and use that reference qualifier with the script to get the "sys ids", then you will have the ability to show the application names.