Script to apply template based on incident category - what is missing

Community Alums
Not applicable

I am trying to create a script for the service catalog record producer to create an incident from the self-service portal.

I need this script to create an incident and automatically assign it to specfiic groups based on 1) the user location 2) incident category 3) assign a template with the assignment group.

Here is the script I have. Everything works except the bottom half if statements for the category "Inquiry / Help" and category "Applications". 

It will not assign the assignment group in the created ticket. It adds the assignment group based on user location.

Please help!

 

 

current.caller_id = gs.getUserID();
current.location = gs.getUser().getLocation();
var grLookup = new GlideRecord("dl_u_assignment");
grLookup.addQuery("location", gs.getUser().getLocation());
grLookup.query();
if (grLookup.next()) {
    current.assignment_group = grLookup.assignment_group;
}
current.contact_type = "self-service";
current.impact = 2;
current.urgency = 2;
current.priority = 3;
if (current.category == "ERP") {
    if (current.subcategory == "D365") {
        if (current.u_level3_category == "Production Control") {
            current.applyTemplate("ERP - Production Control");
        } else if (current.u_level3_category == "Inventory Management") {
            current.applyTemplate("ERP - Inventory Management");
        } else if (current.u_level3_category == "Master Planning") {
            current.applyTemplate("ERP - Master Planning");
        } else if (current.u_level3_category == "Modules") {
            current.applyTemplate("ERP - Modules");
        } else if (current.u_level3_category == "Procurement and Sourcing") {
            current.applyTemplate("ERP - Procurement and Sourcing");
        } else if (current.u_level3_category == "Product Information Management") {
            current.applyTemplate("ERP - Product Information Management");
        } else if (current.u_level3_category == "Sales and Marketing") {
            current.applyTemplate("ERP - Sales and Marketing");
        } else if (current.u_level3_category == "Tablet") {
            current.applyTemplate("ERP - Tablet");
        } else if (current.u_level3_category == "Warehouse Management") {
            current.applyTemplate("ERP - Warehouse Management");
        } else if (current.u_level3_category == "Finance") {
            current.applyTemplate("ERP - Finance");
        }
    }
}
if (current.category == "Inquiry / Help") {
    if (current.subcategory == "HR  (Do Not Include Confidential Info)") {
        current.applyTemplate("HR Incidents");
    }
}
if (current.category == "Applications") {
    if (current.subcategory == "Workday") {
        current.applyTemplate("HR Workday Incidents");
    }
}
gs.addInfoMessage("Thank you - we'll take a look and see what we can do to help");
 
 
Thank you
2 REPLIES 2

Medi C
Giga Sage

Hi @Community Alums,

 

Did you check if you have any "Assignment rules" set for your table? Could you check the history of the assignment group field to check if it gets updated after the record gets inserted? 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

Community Alums
Not applicable

There re assignment rules for location to assigned service desk group. The group I want HR incidents assigned to is brand new have no records associated with it. I have tested my script in dev and the if statements for ERP work, just not the ones for HR.