- 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-13-2024 11:51 PM - edited 08-13-2024 11:54 PM
Use a display business rule to query Task SLA table, check the value of "has_breached" attribute and save the result in g_scratchpad variable. Then use setSectionDisplay method of the g_form API in an onLoad client script to show or hide "SLA Breached Reason" section depending on the value saved in g_scratchpad.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-15-2024 02:36 AM
Its also a great idea do you have a sample?

- 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 12:52 AM
Although this is a valid approach, using a display business rule is better in terms of performance than making a GlideAjax call as it does not require a extra round-trip to the server.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/