how to do variable editor read only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-11-2017 11:28 PM
I have a requirement to make the variables under Variable Editor Read-Only once an INTAKE is generated (from a submission of a Service Catalog).
function onLoad() {
var template = g_form.getValue('u_template');
if (template != "28c64a0837f1cf00548b53b543990efd"){
var sections = g_form.getSections();
sections[2].style.display = 'none';
sections[2].style.display = 'none';
//To do variable editor read only
$(variable_map).select("item").each(function (elmt){
alert('hi');
try {
alert('qname453467568');
g_form.setDisabled('variables.' + elmt.getAttribute('qname'),true);
alert('qname');
} catch (err) {
}
});
//
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 12:09 AM
Hi,
First of all, you will have to apply the client script on the table as I mentioned.
In service Portal, the way to associate a variable editor is as per below article, I think you must have done this:
https://hi.service-now.com/kb_view.do?sysparm_article=KB0621064
So it asks us to create a new widget by cloning the sp-variable-editor widget. So in the cloned widget you should add
Below line:
// Added to make variables read only
data.sc_cat_item._fields[f].readonly = true;
after the line
if (typeof values[f] != "undefined" && typeof values[f].value != "undefined") {
in the server side code.
Regards,
Avinash
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 12:26 AM
Hi avinash,
already variable editor is their on intake table, now please tell me where i have to add this code.
actually, variable editor has been added by creating ui formattor on intake table :by using this macro "com_glideapp_questionset_default_question_editor"
now please tell me where i have to write script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 12:33 AM
Hi,
Did you go through the link. OOTB in SP you don't have variable editor. It is not possible to use a UI formatter in the SP, not supported as of now.
So, what we need to do is to check the widget which is being used for variable editor in your instance. All this is written in the KB article I have shared. In the widget, you need to make the change in the server code. below the line
if (typeof values[f] != "undefined" && typeof values[f].value != "undefined") {
you need
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 12:42 AM
ok. for now if it is working in ESS it is enough for me. Just tell me which can be used for ESS only
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-12-2017 01:06 AM
Just use the onLoad client script with below code:
g_form.setVariablesReadOnly(true);
Regards,
Avinash