Business rule to set assigned to and assignment group when new incident is created from Backend

Nasir
Giga Contributor

HI All,

I need to create a Business rule that would check if opened by is member of Service Desk then set field values of assigned to, to the user who opened the ticket and assignment group to Service Desk.

 

 

1 ACCEPTED SOLUTION

Write a Display BR to check if the the logged in User is member of group or not.

 

g_scratchpad.membership = gs.getUser().isMemberOf('Service Desk');

 

Then you can create an onLoad client script and Use the following code:

 

function onLoad() {

    if (g_form.isNewRecord()) {
        if (g_scratchpad.membership) {
            g_form.setValue('assignment_group', 'sys id of ServiceDesk group');
            g_form.setValue('assigned_to', g_user.userID);
        }
    }

}

 

View solution in original post

5 REPLIES 5

AnirudhKumar
Mega Sage
Mega Sage

If you want to set a static assigned to and assignment group value, below is the code.

 

Use a Before insert business rule for this:

current.assigned_to = 'anyUserID';

current.assignment_group = 'anyGroupID';

 

 

However, ServiceNow has made life easier with Assignment Rules.

Go to this module called Assignment Rules , select your table as incident and set your assignment group and assigned to.

 

 

 

Long Live ServiceNow!

Hi Anirudh,

 

Thanks for your reply mate, however a bit confused with setting static assigned to values. What I am hoping to achieve is when New incident form is loaded, business rule should check if current user or user who is creating the incident is member of Service Desk group. 

If user is member of the group then set assigned_to,  to opened by user and assignment group to service desk, if its not true then leave both the fields emply.

 

I am not really good with scripting as yet so was hoping if someone had done this in the past and would be able to share how they achieved it.

Write a Display BR to check if the the logged in User is member of group or not.

 

g_scratchpad.membership = gs.getUser().isMemberOf('Service Desk');

 

Then you can create an onLoad client script and Use the following code:

 

function onLoad() {

    if (g_form.isNewRecord()) {
        if (g_scratchpad.membership) {
            g_form.setValue('assignment_group', 'sys id of ServiceDesk group');
            g_form.setValue('assigned_to', g_user.userID);
        }
    }

}

 

Perfect, exactly what I was looking for, thanks for your help mate 🙂