Call an array in the Catalog Client Script

xhensilahad
Tera Expert

Good afternoon,

I am trying to pass an array from a Script Inlcude to a Catalog Client Script.

I have tested my Script Include at it is returning the correct values, as a coma separated list.

I want to call this list in my Catalog Client Script, and hide all these variables.

 

Please can you help me with my Catalog Client Script.

 

Script Include:

(Client Callable is true)

var VariableTypeChecker = Class.create();
VariableTypeChecker.prototype = {
    getVariableTypes: function(ritmSysId) {
    var results = [];
        var ritm = new GlideRecord('sc_req_item');
        if (ritm.get(ritmSysId)) {
            var variables = ritm.variables.getElements();

            for (var i = 0; i < variables.length; i++) {
                var question = variables[i].getQuestion(); // Access variable metadata
                if (question) {
                    var name = question.getName(); 
                    var type = question.getType(); 
                    var value = variables[i].getValue();
                    // Check for checkbox type (type 7) and value 'false'
                    if (type === '7' && value === 'false') {
                        results.push(name); /
                    }
                }
            }
        }
        return results.toString();
    },
    type: 'VariableTypeChecker' 
};
 
Catalog Client Script
 
function onLoad() {
   var ritmSysId = g_form.getUniqueValue();
  
    var ga = new GlideAjax('VariableTypeChecker');
    ga.addParam('sysparm_name', 'getVariableTypes');
    ga.addParam('sysparm_ritmSysId', ritmSysId);
    ga.getXMLAnswer(hideVariables);
 
    function hideVariables(response) {
        var answer = response;
 
        var variableNames = JSON.parse(answer);
       
        for (var i = 0; i < variableNames.length; i++) {
        var variableName = variableNames[i];
        g_form.setDisplay(variableName, false);
             }
         }
    }
 
 
Thank you
6 REPLIES 6

Hi Ashul,

The requirement is:

After a Request is submitted, all the checkboxes that were not checked, have to be hidden from the RITM and the SCTASK.

To identify these variables, I have added the condition type=7 (which is a checkbox) and value if 'false' in the Script Include.

I want to pull this variables in my Catalog Client Script, and hide them from the RITM and SCTASK.

Thank you

Hi Anshul,

I need to hide the unchecked variables from the RITM after the request has been submitted.

Thanks