Visible the variable based on requested for

Surendra6
Tera Contributor

Hello team,

 

We have a requirement for to create a catalog onchange client script if the requested for is a VP or director or CEO then the variable won't be visible to select and otherwise it will be visible to select for remaining people. Please provide a script to achieve this requirement.

 

Thanks!!

1 REPLY 1

SAI VENKATESH
Tera Sage
Tera Sage

Hi @Surendra6 

You can try the below script 

On change client script

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var requestedFor1 = g_form.getValue('opened_by');
   //alert(requestedFor1);

    var ga = new GlideAjax('GetManagerDetailsScript');
    ga.addParam('sysparm_name', 'getVipvalue');
    ga.addParam('sysparm_requested_for1', requestedFor1);
    ga.getXMLAnswer(callback);

    function callback(response) {
        var answer = response;
        alert(answer);
        if (answer == 'true') {
            alert("tetsing"); // change the line based upon your need
        } else {
            alert('testing failed'); // change the line based upon your need
        }
    }

   //Type appropriate comment here, and begin script below
   
}

 

Script include :

 

var GetManagerDetailsScript = Class.create();
GetManagerDetailsScript.prototype = Object.extendsObject(AbstractAjaxProcessor, { 
getVipvalue: function() {
        var requestedFor = this.getParameter('sysparm_requested_for1');
        var gr = new GlideRecord('sys_user');
        gr.addQuery('sys_id', requestedFor);
        gr.query();
        if (gr.next()) {
            return gr.vip;
        }
}
});

 

 

Thanks and Regards

Sai Venkatesh