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
11-01-2023 02:02 AM
You need to return a query in a reference qualifier, so it's like
example:
javascript: "sys_idIN" + new CRFAddextusersshowCIList().getCIIDs(gs.getUserID());
Some examples:
https://docs.servicenow.com/en-US/bundle/vancouver-platform-administration/page/script/server-script...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2023 11:57 PM
I get the expected result when I tried from Background
How to use the same in Script include. Can someone please help
@Ankur Bawiskar @Sandeep Rajput @Peter Bodelier @Danish Bhairag2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2023 01:08 AM
Hi @DB1
You are getting the results because you can print the display value of a reference field.
Question is, do you need the u_m2m_sys_user_cmdb_ci_service records to be referenced in your variable, or the u_application_name table?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
