[Tips & Tricks] Autoselect SLA for Service request based on User Site info

[Tips & Tricks] Autoselect SLA for Service request based on User Site info


One of our community users requested the following requirement, to autoselect SLA on a Service request based on the requester's site i.e When a requester submits a service request, based on the requester's site one of the SLA associated with the particular template should get autoselected on the request. This requirement can be fulfilled with help of a script, we thought sharing the script along with configurations steps will be useful for other community users.

Let say there are 2 sites(Mexico and New Jersey) in an organization, user John is associated with the "New Jersey site" and Leo is associated with the "Mexico site".There are 2 service templates ("User On-Boarding" and "Remote Access to Fileserver"). Each service template are associated with 2 SLA's ("SLA_MX_8Hrs" and "SLA_NJ_8Hrs")


Sample Script:

setTimeout(function(){

  var requester_site = $CS.getValue("REQUESTER.SITE");

  var SLA = "Select";

  if (requester_site === "Mexico") {

    SLA = "SLA_MX_8Hrs";

  } else if (requester_site == "New Jersey") {

    SLA = "SLA_NJ_8Hrs";

  }

  jQuery('[id^=servicesla_option_]:contains("' + SLA + '")').trigger("click");

},400);


Prerequisites:

>> Associate ("SLA_MX_8Hrs" and "SLA_NJ_8Hrs") in the Service template "User On-Boarding".


 

>> FAFR, On-Form load, copy the script to FAFR and refer to the screenshot given below.



>> When Leo submits the service request using the template "User On-Boarding"Based on Leo’s site "Mexico" the SLA "SLA_MX_8Hrs" gets autoselected on service request.

>> Similarly when John submits the service request using the template "User On-Boarding".Based on John's site  "New Jersey" the SLA "SLA_NJ_8Hrs" gets autoselected on service request.


Thank you for your time, we hope you find this article useful!

Our previous article was on - Preventing Request Closure when there are Pending Approvals