On Kingston g_form.setVariablesReadOnly(true); script on task is no longer working

kkingsle
Tera Expert

We're in the process of upgrading from Helskini (Patch12) to Kingston (Patch2).  We have a standard variable set with am  Onload client script to lock down all variables on a Catalog task from to read only, which basically only includes  g_form.setVariablesReadOnly(true);  (there is an additional line to  a specific variable to g_form.setReadOnly(false);

 I can't find any reference to that g_form in the documentation, but this was working in Helsinki, but not in Kingston.  Is this expected behavior?

 

There was a comment in another thread about this working on the Item, but not task and I posted a comment there, but haven't gotten any clarification yet.

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

I just tried this on Kingston Patch1 and it worked. I think there is something failing in you catalog script, which is blocking this client script.

Must be some error on the form. Check for that

 

function onLoad() {
//Type appropriate comment here, and begin script below

g_form.setVariablesReadOnly(true);
}


Please mark this response as correct or helpful if it assisted you with your question.

kkingsle
Tera Expert

I can recreate it consistently, including on my developer instance using a new service with only that line in the script, and no other policies/scripts.  I've opened a ticket in HI, when I get the results, I'll update.

Sakar Sawarkar
ServiceNow Employee
ServiceNow Employee

Our rule of thumb is to say, if it is not documented, avoid using it, since we will not support it. This is due to the fact that in the event of it breaking in your environment, or if the API changed, the Support organization would not be able to provide any assistance in that situation, unfortunately.

Please check this community article. 

Create read-only variable editors

This seems to solve the problem mentioned above. 

jaredspears
Kilo Contributor

There are two methods that I have found to work in Kingston (We are on Kingston Patch 3).

Method 1 (Catalog Client Script):

Modify the existing Catalog Client Script which is not working to reflect the following:

function onLoad() {

//Type appropriate comment here, and begin script below

//Commented out for Kingston compatability

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

}

 

Method 2 (UI Policy):

Create a UI Policy with the original code from the Catalog Client Script that is not working. (e.g. g_form.setVariablesReadOnly(true);)

Short Description: OL - RITM ReadOnly Variables

Reverse if false = false(unchecked)

On load = true(checked)

Run scripts = true(checked)

Active = true(checked)

Applies on a Catalog Item view = false(unchecked)

Applies on Catalog Tasks = true(checked)

Applies on Requested Items = true(checked)

Execute if true:

function onCondition() {
g_form.setVariablesReadOnly(true);
}

Execute if false:

function onCondition() {

}