g_form.setVariablesReadOnly(false) not working for all variables in VEditor

Raphael Dizon
Mega Expert

Hello,

I have tried creating a client script in ritm table so that variables in VEditor won't be read only, I used g_form.setVariablesReadOnly(false); and it only made some fields editable but not all, why is that?

find_real_file.png

13 REPLIES 13

Hi Swapnil,

I've tried using that as well but still it doesn't work

function onLoad() {

var itm = g_form.getValue('cat_item');
var sid = g_scratchpad.property;

var atype = g_form.getValue('variables.access_type');

if(itm == sid){

if(atype == 'Group Access'){
//g_form.setVariablesReadOnly(false);
g_form.setReadOnly('variables.ad_group', false);
g_form.setReadOnly('variables.resource_group', false);
g_form.setReadOnly('variables.resource_1', false);

}

}

}

I tried using g_form.setVariablesReadOnly(false); just to see if it will set all the variables to be editable, but it only makes some variable editable and others are still read-only, I have checked my Catalog's UI Policies and scripts but it doesn't have a set to read only

Hi,

can you try this code-

function onLoad() {
if(document.getElementById('variable_map')){
$(variable_map).select("item").each(function (elmt){
try {

g_form.setDisabled('variables.' + elmt.getAttribute('qname'),false);
} catch (err) {
}
});

}

 

Hi,

Do I put the catalog item in the $(variable_map).select("item").each(function (elmt){ ?

And what is the value of qname in g_form.setDisabled('variables.' + elmt.getAttribute('qname'),false);

I had the same issue and was solved creating an onload script with the following code

 

function onLoad() {
    // g_form.setVariablesReadOnly(true);
    $("variable_map").querySelectorAll("item").forEach(function(item) {
        var variable = item.getAttribute("qname");
        g_form.setReadOnly("variables." + variable, true);
    });

}

 

*** Observation: Multi Row Variable set is not covered by this script. For this type of variable I set the Variable Set field Write roles only for admin. This will make the variable set read only in fullfilment view