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

Hi Tim,



Yeah I was thinking that too, so am trying just to change the Impact field first.  



If I were to use the example above from Mike, I think there may need to be some form of reference to the field Impact or should g_form.setValue('impact', 2) automatically set the value on the impact field to 2



I'm not an expert in Javascript, so learning as I go (hence, may take me a little longer)


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


Hi Tim,



Thanks for this,   I think I had to set both the impact and urgency for this to take effect and this works perfectly



Thanks again for your help - seems a lot easier than creating custom tables!



Shona