Need Assistance with ref qualifier

Community Alums
Not applicable

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

2 ACCEPTED SOLUTIONS

Try below one, I have made few changes

 

javascript&colon; (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

 

View solution in original post

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&colon; 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

 

View solution in original post

9 REPLIES 9

surajchacherkar
Mega Guru

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! 

 

 

 

 

Community Alums
Not applicable

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. 

surajchacherkar
Mega Guru

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&colon; (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

Community Alums
Not applicable

Hi @surajchacherkar,

I tried above script but its not working