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 08:22 AM
Actually there is no User table reference at all on the catalog item
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 06:14 AM
If it's a variable within a catalog item it's called client sided, I'm guessing it should be a GlideAjax?
Other then this being commented and will not fill the array ofcourse:
//usersList.push(gruser_list.getUniqueValue());
Also your not filling the list correctly at the moment
getCIIDs: function(a){
var usersCmdbCIList = [];
var grUserCmdbCI= new GlideRecord('u_m2m_sys_user_cmdb_ci_service');
grUserCmdbCI.addQuery('sys_user', gs.getUserID());
grUserCmdbCI.query();
while(grUserCmdbCI.next()) {
usersCmdbCIList.push(grUserCmdbCI.getUniqueValue());
//usersCmdbCIList.push(grUserCmdbCI.getDisplayValue('u_cmdb_ci_service.u_application_name'));
//Your not pushing it so it will only take the last of the query
//var list = gruser_list.getDisplayValue('u_cmdb_ci_service.u_application_name');
}
return usersCmdbCIList;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 07:38 AM
I need to display the Application names though. How to do it?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 07:51 AM
Use the one that commented out:
//usersCmdbCIList.push(grUserCmdbCI.getDisplayValue('u_cmdb_ci_service.u_application_name'));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2023 08:12 AM
Ok thank you, should I call the script include on Ref qualifier as below?
javascript: new CRFAddextusersshowCIList().getCIIDs(current.sys_user)
