Upon resolving an Incident, how can you show a Breach Reason field

Michael  Snow
Giga Contributor

I've created a Breach Reason field to help track why we missed hitting SLAs.   I would like to only show this field and make it mandatory when the ticket has been breached, but I have not been able to figure out how to do so.

 

The field has been created in the INCIDENT table so it can show up on the incident form, but the SLA information I want is in the TASK_SLA table.

 

I appreciate your consideration and any help you might be able to offer in this regard.

 

Thank you,

 

Michael Snow

5 REPLIES 5

prabh
Mega Expert

Hi Michael,



Please let me know, how did you accomplish this requirement.



Thanks & Regards,


Preety Arora.


marcguy
ServiceNow Employee
ServiceNow Employee

you would either need to evaluate whether it's breached a)upon selecting resolved via client script b)evaluate whether it's breached on display in a BR, I went for the Display BR method:



checkforBreached();




function checkforBreached(){


g_scratchpad.hasbreached = false;


    var ct = new GlideRecord('task_sla');


    ct.addQuery('task', current.sys_id);


    ct.addQuery('sla.type','SLA');


    ct.addQuery('has_breached',true);


    ct.query();


if (ct.next()){


g_scratchpad.hasbreached = true;


}


}




so that passes the hasbreached scratchpad value into the client which means you don't need to evaluate anything client side except the scratchpad value:



client script onchange of incident state to resolved:



    if (g_scratchpad.hasbreached == true) {


          g_form.setDisplay('u_reason_for_sla_breach',true);


          g_form.setMandatory('u_reason_for_sla_breach',true);


    }



else {


          g_form.setDisplay('u_reason_for_sla_breach',false);


g_form.setMandatory('u_reason_for_sla_breach', false);


    }


Please check below thread



https://community.servicenow.com/thread/167464



This is also an another way to do this task.



Many Thanks !!


Preety Arora.


I am sorry, but that was not completed.   But it looks like mguy has addressed it below