I need set priority of incident category and sub category

Saranya K
Tera Contributor

Hi all,

 

I need to set priority of incident when  category is HRMS and sub category is anyone of and i tried below not working

and i have in one more onchange script on category it worked as expected but when i choose subcategory the values get wiped.

can anyone help me on this.

 

SaranyaK_0-1734939861998.png

 

5 REPLIES 5

vishwajeet5550
Mega Guru

It sounds like you're trying to set the priority of an Incident record when the category is "HRMS" and the subcategory is set to any value, but you're facing an issue where the value gets wiped when you change the subcategory.

The issue could be related to the order in which the onChange client scripts are executed and how the values are being set. If you have two client scripts on the category and subcategory fields, one may be overriding the values set by the other, causing unexpected behavior

function onChange(control, oldValue, newValue) {
    var category = g_form.getValue('category');
    var subcategory = g_form.getValue('subcategory');
    if (category == 'HRMS' && subcategory) {
        g_form.setValue('priority', '2'); // Example: Set priority to "2" (High priority)
    } else {
        g_form.setValue('priority', '3'); // Example: Set priority to "3" (Normal priority)
    }
}


function onCategoryChange(control, oldValue, newValue) {
    var subcategory = g_form.getValue('subcategory');
    if (newValue == 'HRMS' && subcategory) {
        g_form.setValue('priority', '2'); 
    }
}

 

 

Combining the logic for category and subcategory into one script will prevent race conditions where one script is overwriting the other.

Ensure that the priority is set based on the correct conditions and that no script inadvertently resets it.