client script on incident table

krajrajput2111
Tera Contributor

i want when category = software make priority = 1-critical (which is derived from the values of Impact and Urgency fields), else display the old value when the form loaded.

4 REPLIES 4

Juhi Poddar
Kilo Patron

Hello @krajrajput2111 

To meet your requirement refer the screenshot and script below:

Configuration setup:

JuhiPoddar_0-1737961166870.png

Client script:

 

function onLoad() {
   //Type appropriate comment here, and begin script below
    var category = g_form.getValue('category');
   
    // Set priority if category is "Software"
    if (category == 'software') {
        g_form.setValue('impact','1');
        g_form.setValue('urgency', '1');
        g_form.setValue('priority', '1');
    }
    // No change if category isn't "Software"
}

 

Hope this helps!

 

"If you found my answer helpful, please like and mark it as an "accepted solution". It helps future readers to locate the solution easily and supports the community!"

 

Thank You
Juhi Poddar

i tried this already, thing is when software is selected it works fine, but without saving when category is selected to some other value say Network, still it shows 1- critical.

krajrajput2111
Tera Contributor

.

Harish Bainsla
Tera Sage
Tera Sage

Hi @krajrajput2111  try below code 

function onLoad() {
    //Type appropriate comment here, and begin script below
    var old = g_form.getValue('priority');
    var Cat = g_form.getValue('category');
    if (Cat == 'software') {
        g_form.setValue('priority', '1');
    } else {
        g_form.setValue('priority', old);
    }
}
if my answer helps you mark helpful and accept solution