- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 06:39 PM
Hello, everyone.
I have a catalogue item with three variables. The first is requested for (reference to the user table), the second is Application Name (reference to the application table), and the third is the CheckBoxType variable. If the checkbox type variable is checked, the second variable will display only the applications owned by the requestedFor, otherwise it will display all applications. Please indicate how I should address this requirement.
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 07:05 PM - edited 06-12-2024 07:08 PM
Try below one, I have made few changes
javascript: (function() { if (current.variables.<checkbox_type_variable_name> == 'false') {return;} else { return ('owned_by=' + current.variables.<req_for_variable_name>);} })();
If my response helped you, please click on "Accept as solution" and mark it as helpful.
Thanks
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 12:05 AM
Hi @Community Alums,
If you want to achieve it by calling script Include in reference qualifier then refer below script, use Javascript syntax line in advance reference qualifier of Application Name variable.
javascript: new test1234().getStoreIDs(current.variables.checkbox, current.variables.req_for);
//Script Include(Client Callable):
var test1234 = Class.create();
test1234.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getStoreIDs: function(b, a) {
var suraj = [];
var user = a.toString();
if (b == 'true') {
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('owned_by' , 'IN', user);
gr.query();
while (gr.next()) {
var xyz = gr.sys_id.toString();
suraj.push(xyz);
}
} else {
var gr1 = new GlideRecord('cmdb_ci_computer');
gr1.addEncodedQuery('virtual=false');
gr1.query();
while (gr1.next()) {
var abc = gr1.sys_id.toString();
suraj.push(abc);
}
}
return 'sys_idIN' + suraj;
},
type: 'test1234'
});
If my response helped you, please click on "Accept as solution" and mark it as helpful.
Thanks
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 07:05 PM - edited 06-12-2024 07:08 PM
Try below one, I have made few changes
javascript: (function() { if (current.variables.<checkbox_type_variable_name> == 'false') {return;} else { return ('owned_by=' + current.variables.<req_for_variable_name>);} })();
If my response helped you, please click on "Accept as solution" and mark it as helpful.
Thanks
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 07:11 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 07:18 PM
Sure @Community Alums, FYI, you can also achieve it by calling script include in advance reference qualifier of Application Name variable.
If my response helped you, please click on "Accept as solution" and mark it as helpful.
Thanks
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 11:31 PM
Hi @surajchacherkar, it's working as expected, Thanks for the help!🙂🙏
As you mentioned in previous chat we can also achieve it by calling script Include in reference qualifier, If you have sample script can you please share, Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2024 12:05 AM
Hi @Community Alums,
If you want to achieve it by calling script Include in reference qualifier then refer below script, use Javascript syntax line in advance reference qualifier of Application Name variable.
javascript: new test1234().getStoreIDs(current.variables.checkbox, current.variables.req_for);
//Script Include(Client Callable):
var test1234 = Class.create();
test1234.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {
getStoreIDs: function(b, a) {
var suraj = [];
var user = a.toString();
if (b == 'true') {
var gr = new GlideRecord('cmdb_ci_computer');
gr.addQuery('owned_by' , 'IN', user);
gr.query();
while (gr.next()) {
var xyz = gr.sys_id.toString();
suraj.push(xyz);
}
} else {
var gr1 = new GlideRecord('cmdb_ci_computer');
gr1.addEncodedQuery('virtual=false');
gr1.query();
while (gr1.next()) {
var abc = gr1.sys_id.toString();
suraj.push(abc);
}
}
return 'sys_idIN' + suraj;
},
type: 'test1234'
});
If my response helped you, please click on "Accept as solution" and mark it as helpful.
Thanks
Suraj