Set Priority based on another field

shonamac
Kilo Expert

Hi,

I'm trying to set up a rule that if a user selects a specific category the priority will be set at a specific value.   E.g Subcategory = Phishing Email, Priority = 2 - High

I think what I need to do is create a custom data lookup table & definition record and then a client script

Am I going about this the right way, or am I wrong and there's a better way to do this?

Thanks

Shona

1 ACCEPTED SOLUTION

Community Alums
Not applicable

Try this client script:



Table: Incident


Type: OnChange


Field Name: subcategory



Script:



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


    if (isLoading || newValue == '') {


          return;


    }




  if(newValue == 'antivirus') {


  g_form.setValue('impact', 1);


  g_form.setValue('urgency', 1);


  }


   


}




I just tested this on my dev instance, and it works as expected (sets priority to Critical). Obviously, you would need to modify for your proper subcategory value and impact/urgency values.



Hope that helps!



Cheers,



Tim


View solution in original post

7 REPLIES 7

Mike Allen
Mega Sage

You could have an onChange client script that says:


onChange subcategory



if(newValue == 'Phishing Email'){


        g_form.setValue('priority', 2);


}


Namrata Makasa1
Giga Expert

hey,



you can create a custom lookup table if you need


hope the following thread helps:


Data Lookup and Record Matching Support - ServiceNow Wiki


Hey Namrata,



That was the avenue I was originally going down, but it seemed quite convoluted for what I was trying to do (also I'm unable to add any setter field definitions - which is weird)



Mike, I'm trying out your suggestion but not getting anywhere fast so will persevere longer


Community Alums
Not applicable

Are you utilizing (as in, you haven't disabled the functionality) the out-of-box data lookup on the priority field?



find_real_file.png




I'm wondering if using a client script to change the priority field value will not make a difference given the priority field is read only and the value is driven by the impact/urgency field values. Maybe try changing the impact/urgency fields instead, which will in turn drive the priority field value.