How to Set Read only for Incident variable Editor on incident form

Srinivasu2
Tera Contributor

Hi Community,

 

I have created a high severity portal form using the Record Producer, and it has been placed in the ESC Portal.

 

And I have included the 'Incident Variable Editor' on the incident form whenever a user submits the above form from the ESC portal. Then, the incident variable editor is visible as shown below

 

Srinivasu2_0-1715167552709.png

 

The requirement is to set the Incident Variable Editor on the incident as read-only

 

Please help me with how to set the Incident Variable Editor to read-only

 

Thanks,

Srinivasu

 

1 ACCEPTED SOLUTION

Ramz
Mega Sage

Hi @Srinivasu2 ,

To set the Variable Editor to read only a different table like incident, please follow these steps:

  1. Create a Client Script on the Incident table
  2. Paste the following script:
    function onLoad() { 
    $("variable_map").querySelectorAll("item").forEach(function(item){
    var variable = item.getAttribute("qname"); 
    g_form.setReadOnly("variables."+ variable, true); 
    }); 
    }
  3. This will require to uncheck (set to false) the "isolate script" checkbox (This checkbox is not on the form by default) Steps below how to bring it to the form)
    1. To do that right click in the header -> Configure -> Form Layout
    2. On the left side find "Isolate script" and bring it to the right and save
  4. Save changes
    This should make the Variable Editor on the incident table read-only

Please follow this article for further reference :https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0752560

 

Please mark my answer correct/helpful if it resolved your query

View solution in original post

6 REPLIES 6

Sid_Takali
Kilo Patron
Kilo Patron

Hi @Sid_Takali ,

 

Thank you for quick response,

 

I need solution Incident form, I pulled the "Incident variable editor" from available to selected in slush bucket in incident form

 

how can we set read-only on "Incident variable editor" on incident form

 

Thanks,

Srinivasu

 

 

Nadir Abbas
Tera Contributor

Hi, 
you have to go the Navigational filter and type the "sys_ui_macro.LIST". Here you have to find the record which name is "com_glideapp_questionset_default_question_editor". 
Just open it and paste the script which is given below:

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
    <g:requires name="scripts/js_includes_catalog.js" includes="true"/>
    <g:requires name="styles/${new CatalogCssSelector().getVariableCss()}" includes="true"/>
    <g:if_polaris>
       <g:then>
         <g:requires name="styles/${new CatalogCssSelector().getPolarisVariableCss()}" includes="true"/>
      </g:then>
    </g:if_polaris>
    <g2:evaluate var="jvar_catalog_item">
       function eval_cat_item() {
        var cat_item = "";
        var catItemProducedGr = new GlideRecord("sc_item_produced_record");
        catItemProducedGr.addQuery("record_key", current.getUniqueValue());
        catItemProducedGr.query();
        if (catItemProducedGr.next())
            cat_item = catItemProducedGr.getValue("producer");
        return cat_item;
       }
       eval_cat_item();
    </g2:evaluate>
   
    <!-- load only the one_to_one variable sets -->
    <g2:evaluate var="jvar_cat_sets" jelly="true">
       var jvar_cat_sets = "";
       var gr = new GlideRecord("io_set_item");
       gr.addQuery("sc_cat_item", jelly.jvar_catalog_item);
       gr.addQuery("variable_set.type", "one_to_one");
       gr.query();
       while (gr.next()) {
          if (jvar_cat_sets.length > 0)
             jvar_cat_sets += ",";
          jvar_cat_sets += gr.variable_set;
       }
       jvar_cat_sets;
    </g2:evaluate>
   
    <g2:evaluate var="jvar_questionset_read_only" jelly="true">
        <!-- (gs.getProperty('glide.sc.evaluate.variables.write.access', true) == 'true') ? !current.variables.canWrite() : !current.canWrite(); -->
        true;
    </g2:evaluate>

    <div data-sn-macro-sys-id="${jvar_macro_sys_id}">
        <j2:if test="$[jvar_catalog_item != '']">
            <j2:set var="jvar_producer_target_record" value="true"/>
            <g2:client_script type="catalog_question_editor" catalogItem="$[jvar_catalog_item]"/>
            <g:inline template="catalog_ui_policy.xml"/>
            <g2:render_component componentName="com.glideapp.servicecatalog.DefaultQuestionEditor"/>
        </j2:if>
        <j2:if test="$[jvar_catalog_item == '']">
            <!--Render old default editor if catalog item is not found -->
            <g2:render_component componentName="com.glideapp.questionset.DefaultQuestionEditor"/>
        </j2:if>
    </div>
</j:jelly>

AmeliaLouise_0-1715170382880.png

 


If you find this helpful to you then mark it.
Regards Amelia