script to auto populate the assignment group on an INC record producer service catalog item

Community Alums
Not applicable

Can anyone please help me figure out how to get this script to work?

This is an INC record producer from the self-service catalog Get Help catalog item.

The last two "else if" statements are not working.

It is not applying the incident templates to incidents that are created with Category = "Inquiry / Help" and Subcategory = "HR  (Do Not Include Confidential Info)" 

same for incidents created with Category = "Applications" and subcategory = "Workday"

It is not applying the templates listed. The ERP if statements are working fine, just not the HR ones at the bottom of the script.

What am I missing?

 

 

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");
        } else if (current.category == "Inquiry / Help") {
                if (current.subcategory == "HR  (Do Not Include Confidential Info)") {
                    current.applyTemplate("HR Incidents");
        } else 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");
 
 
 
 
Any assistance is greatly appreciated.
Thank you
1 ACCEPTED SOLUTION

Brad Bowman
Kilo Patron
Kilo Patron

You need to make sure you are using the correct values for the choices, not Label, so Inquiry / Help is likely 'inquiry'.  Additionally, the logic doesn't make sense at first glance with these conditions nested inside of category = ERP and subcategory = D365, how can the Category be Inquiry / Help?

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

You need to make sure you are using the correct values for the choices, not Label, so Inquiry / Help is likely 'inquiry'.  Additionally, the logic doesn't make sense at first glance with these conditions nested inside of category = ERP and subcategory = D365, how can the Category be Inquiry / Help?

Community Alums
Not applicable

There are several categories and several options for each category.

Your suggestion for the label vs value was definitely my issue and the script now works as intended.

Thank you very much for this easy fix!

You are welcome!

Community Alums
Not applicable

This worked!

 

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") {
if (current.subcategory == "hr") {
current.applyTemplate("HR Incidents");
}
}
if (current.category == "application") {
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");