Hiding variable on RITM and Task

Cirrus
Kilo Sage

Hi,

We have a catalog item that contains a variable set called Delivery Options. This set contains a number of variables, one of which is delivery_address for home delivery, which is made visible by a ui policy if another choice variable= home. We would like to hide this variable on the RITM for everyone, and on the sc_task for everyone other than members of the fulfilling group - this bit is working fine. To achieve this we have an on load client script which applies on the RITM and task, UI Type = All with the script below, but the variable is still showing on the RITM. We have tried the client script within the set, on the item, applying to the variable set and applying to the item, but in all cases the RITM still shows the address. We also use this script in another item, where it does hide the address on the RITM, but in this case the address is a stand alone variable. Can anyone suggest why this doesnt work for variable sets?

function onLoad() {
   
    var tableName = g_form.getTableName();
    
    if (tableName == 'sc_req_item') {
        g_form.setDisplay('delivery_address', false);
    }
        if (tableName == 'sc_task') {
        var ga = new GlideAjax('BespokePortalUtils');
        ga.addParam('sysparm_name', 'isUserInGroup');
        ga.addParam('sysparm_group', g_form.getValue('assignment_group'));
        ga.getXMLAnswer(ajaxResponse);
        }
}

function ajaxResponse(response) {
    var answer = response;
    if (answer == 'false') {
        g_form.setDisplay('delivery_address', false);
    }

}

 

 

 

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron
Hi Can you Try this since it is variable it should be like this g_form.setVisible('variables.delivery_address',false);
Regards
Harish

View solution in original post

3 REPLIES 3

Harish KM
Kilo Patron
Kilo Patron
Hi Can you Try this since it is variable it should be like this g_form.setVisible('variables.delivery_address',false);
Regards
Harish

Thanks Harish, that works, although still a little confusing why setDisplay works on task but not on RITM

for variables you have to use

g_form.setDisplay('variables.variablename',false);

Regards
Harish