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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 01:16 AM
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?
- Labels:
-
Scripting and Coding
-
Team Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 02:50 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 04:28 AM
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) {
}
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2020 06:33 PM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 05:44 AM
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