Hiide details section in incident form

Rajveer
Tera Expert

Hello Experts

if variable editor is empty in details section on  incident then hide details section in incident form.
Could you help me in script .I tried using script .But it's not working for me or any other solution.

Script include:

 

var CheckVariableEditor = Class.create();
CheckVariableEditor.prototype = {
    initialize: function() {},
    isVariableEditorEmpty: function(incidentSysId) {
        var gr = new GlideRecord('question_answer');
        gr.addQuery('table_sys_id', incidentSysId);
        gr.query();
        return !gr.hasNext();
    },
    type: 'CheckVariableEditor'
};

 

Onload client Script

 

function onLoad() {
    var ga = new GlideAjax('CheckVariableEditor');
    ga.addParam('sys_id', g_form.getUniqueValue());
    ga.getXMLAnswer(function(response) {
        var isEmpty = response.responseXML.documentElement.getAttribute('answer') === 'true';
        if (isEmpty) {
            g_form.setSectionDisplay('details', false);
        }
    });
}

1 REPLY 1

Sanjay191
Tera Sage

Hello @Rajveer 

Please refer the below article for better undarstanding how to use GlideAjax  and how to pass data from client side to script include using GlideAjax
https://www.basicoservicenowlearning.in/2019/12/glideajax-in-servicenow.html

And also you can hide the form section by using the client script only.

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up. 

Thank You