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

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

 

Community Alums
Not applicable

Hi @surajchacherkar,

 

Let me check, Thanks for the prompt response😊🙏

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

Community Alums
Not applicable

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! 

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