- 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 06:46 PM
Hi @Community Alums,
To achieve the desired functionality, you need to use onChange Catalog Client Scripts to dynamically filter the `Application Name` field based on the state of the `CheckBoxType` checkbox and the value of the `requestedFor` field.
You can also achieve it by calling script include in advance reference qualifier. If you need any Sample script then let me kniw know.
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 06:57 PM
Thanks for the reply @surajchacherkar,
I tried onChange catalog client script but it is not working. Let me try with calling script include in ref qualifier.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2024 06:52 PM
Hi @Community Alums,
You can also call one javascript function like below in advance reference qualifier of Application Name field. It will also work
javascript: (function() { if (current.variables.checkboxsuraj== 'false') {return;} else { return ('assigned_to=' + current.variables.req_for+'^environment='+current.variables.environment_ref_aws);} })();
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:00 PM
Hi @surajchacherkar,
I tried above script but its not working