The CreatorCon Call for Content is officially open! Get started here.

Dynamic SLA Condition using "hasRole"

jonathangilbert
Kilo Sage

Morning,

 

I would like to see if it is possible to have the ability on a SLA Definition that the condition is based on whether the user has a role or not.

At present I have to manually add usernames into the SLA definition, which is not idea. I was think is there a way I could have the conditon based on if the user has a role or not.

sla definition.png

2 REPLIES 2

vignesh parthib
Tera Expert

Hi @jonathangilbert 

 

I believe your trying “pause SLA if user has role”

 

  • you can create a Boolean field on the Task table (Incident, Request, etc.) named e.g., u_user_has_role.

  • Create a business rule on the Task table that updates this field whenever the assigned_to/requested_for changes or record is updated:

  • In your SLA Definition pause conditions, add:  [u_user_has_role] [is] [true]
(function executeRule(current, previous /*null when async*/) {
    var userGR = new GlideRecord('sys_user');
    if (userGR.get(current.assigned_to)) { // Or current.requested_for depending on your need
        if (userGR.hasRole('desired_role_name')) {  // Replace with your role sys_id or name
            current.u_user_has_role = true;
        } else {
            current.u_user_has_role = false;
        }
    } else {
        current.u_user_has_role = false;
    }
})(current, previous);

 

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."

 

Ankur Bawiskar
Tera Patron
Tera Patron

@jonathangilbert 

I think you can use script include and then handle this

1) store the user names in system property

2) use gs.getProperty() or use GlideRecord to get system property value and then use it and return

check this

Implementing complex SLA definitions using decision table and script include 

also see this link and enhance, response from Harsh Vardhan

Can we call script include from SLA filter condition? 

AnkurBawiskar_0-1759478895748.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader