Auto Populate assignment group and assigned to field on Service request

jyotimalhot
Tera Contributor

Hi Team,

 

I'm submitting one Request form from service portal giving category and subcategory. Based on the category chosen, the Assignment group and Assign to must auto picked on Request.

I have configure after Business Rule with below script, Assignment Group is reflecting in Request on chosen category but Assigned to field showing empty.

 

jyotimalhot_0-1733132758635.pngjyotimalhot_1-1733132779491.png

 

 

Business Rule Script:

(function executeRule(current, previous /*null when async*/) {
 
var req = new GlideRecord('sc_request');
req.addQuery('sys_id', current.request);
req.query();
 
if (req.next()) {
    req.requested_for = current.variables.u_requester;
    req.u_category = current.variables.category;
    req.u_subcategory = current.variables.subcategory;
    // Category-based assignment logic
    if (current.variables.category == 'netwok') {
        gs.info("Category set to 'network'");
        req.assignment_group = 'c3a9aa530f6e1640c637fb1792050e04'; // Network and Security Support Group
        gs.info("assigned to 'Network and Security Support Group'");
        req.assigned_to = 'eb5da2170f6e1640c637fb1792050eba'; // RIMS NW Engineer
        gs.info("assigned to 'RIMS NW Engineer'");
        req.u_channel = "Web Portal";
    } else if (current.variables.category == 'windows') {
        gs.info("Category set to 'windows'");
        req.assignment_group = 'd705979d0f9092409935945f62050eb5'; //IRIMS Windows_Team
        gs.info("assigned to 'IRIMS Windows_Team'");
        req.assigned_to = '1be0bce44f229a00ac660f5d0210c726'; // RIMS Windows Engineer
        gs.info("assigned to 'RIMS Windows Engineer'");
        req.u_channel = "Web Portal";
    }
    // IRIMS InfraServices Assignment
    else {
        req.assignment_group = 'd305979d0f9092409935945f62050eb6'; // IRIMS InfraServices
        req.assigned_to = '67c067df0f5d3100703337f692050eeb'; // Correct sys_id for assigned user
    }
   
    req.update();
}
 
 
})(current, previous);
 
 
Thanks & Regards
Jyoti Malhotra
4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

@jyotimalhot 

are you sure that assigned to is part of that group which you are setting?

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

Hi @Ankur Bawiskar 

 

Yes,  assigned to is part of that group.

 

Regards,

Jyoti

@jyotimalhot 

did you check any other BR is clearing the assigned_to or restricting it from getting updated?

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

Hi @Ankur Bawiskar 

 

It's sorted now.

Thanks!

 

Regards

Jyoti