on change client script

Shikhar Srivast
Tera Contributor

i have three on change client scripts running to calculate priority they are
on change of impact,on change of urgency,on change of business criticality
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue === oldValue) {
return;
}
calculatePriority();
}

function calculatePriority() {

var impact = g_form.getValue('impact');
var urgency = g_form.getValue('urgency');
var businessCriticality = g_form.getValue('u_business_criticality');


if (businessCriticality === '1 - most critical') {
businessCriticality = '1';
} else if (businessCriticality === '2 - somewhat critical') {
businessCriticality = '2';
} else if (businessCriticality === '3 - less critical' || businessCriticality === '4 - not critical') {
businessCriticality = '3';
}

var highestValue = impact;
if (urgency > highestValue) {
highestValue = urgency;
}

if (businessCriticality > highestValue) {
highestValue = businessCriticality;
}

g_form.setValue('priority', highestValue);
}
same script i have used in for all 3 fields

the logic is which ever has the highest value the priority should be that
but this is failing in one case
like when i change impact is 1 urgency is 2 and business criticality is 1 the priority changes to 2 which is correct then i change urgency to 3 it doest changes again on first time change of urgency it calaculates then if i change urgency again it doesnt calcultate and this happens withh all three fields

0 REPLIES 0