"SLA Reason Section"

Blitz
Tera Expert

Do you know how to implement use case: If Task SLA [has_breached] is false then the "SLA Breached Reason" section & "Breached Reason" field will not display, I think this can be done in an On load Client script

Just a sample: 

Blitz_0-1723610396149.png

 

1 ACCEPTED SOLUTION

Not applicable

Hi @Blitz ,

 

Write a onload client script and call the script incude using GlideAjax to check if any of the SLA assosciated to the incident is breached or not , if not breached hide the section

 

Note: Section name must in be in lowercase while hidding and also replace firsr space with unserscore and remove next spaces ex: SLA Breached Reason becomes

g_form.setSectionDisplay("sla_breachedreason", false);

 

client scritpt:

function onLoad() {
    //Type appropriate comment here, and begin script bel
    var inc = new GlideAjax("checkSLA");
    inc.addParam("sysparm_name", "breachStatus")
    inc.addParam("id", g_form.getUniqueValue());
    inc.getXMLAnswer(result);

    function result(output) {
        if (output== "not breached") {
            g_form.setSectionDisplay("related_records", false); //replace related_records with your section name
        }
    }

}

Script include:

var checkSLA = Class.create();
checkSLA.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    breachStatus: function() {
        var incSysId = this.getParameter("id");
        var sla = new GlideRecord("task_sla");
        sla.addQuery("task", incSysId);
        sla.query();
        while (sla.next()) {
            if (sla.has_breached) {
                return "breached"; //any one of the SLA is breached
            }
        }
        return "not breached"; //no SLA breached

    },

    type: 'checkSLA'
});

 

ex:

 

HemanthM1_0-1723620775627.png

 

HemanthM1_1-1723620818359.png

 

Hope this helps

 

 

View solution in original post

6 REPLIES 6

Not applicable

Hi @Blitz 

 

Agree, If its only for onLoad, yes, Display BR is best suited, However, if they want to scale this for any changes to the form, they can call the same script include (since Display BR runs once during form load).

 

 

 

We have the same method but different in coding, this works also