- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-13-2024 09:40 PM
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:
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 12:33 AM
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:
Hope this helps
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 01:04 AM
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).
Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-14-2024 01:07 AM
We have the same method but different in coding, this works also