Unexpected constant condition

Community Alums
Not applicable

Hi,

I am using Client Script to get the value of priority. I got the options of impact, urgency, and priority from choice list specification of Task table.

I am trying to use client script to get the value of priority. I am getting "Unexpected constant condition". Kindly help.

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

    if (("u_impact" == '1') && ("u_urgency" == '1')) {
		g_form.setValue("u_piority" == '1');
    }
	else if(("u_impact" == '1') && ("u_urgency" == '2')) {
		g_form.setValue("u_piority" == '2');
    }
	else if(("u_impact" == '1') && ("u_urgency" == '3')) {
		g_form.setValue("u_piority" == '3');
    }
	else if(("u_impact" == '2') && ("u_urgency" == '1')) {
		g_form.setValue("u_piority" == '2');
    }
	else if(("u_impact" == '2') && ("u_urgency" == '2')) {
		g_form.setValue("u_piority" == '3');
    }
	else if(("u_impact" == '2') && ("u_urgency" == '3')) {
		g_form.setValue("u_piority" == '4');
    }
	else if(("u_impact" == '3') && ("u_urgency" == '1')) {
		g_form.setValue("u_piority" == '3');
    }
	else if(("u_impact" == '3') && ("u_urgency" == '2')) {
		g_form.setValue("u_piority" == '4');
    }
	else if(("u_impact" == '3') && ("u_urgency" == '3')) {
		g_form.setValue("u_piority" == '5');
    }


}

 

pr.png

 

Regards

Suman P.

 

1 ACCEPTED SOLUTION

James Chun
Kilo Patron

Hi @Community Alums,

 

Try the following instead:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

	var impact = g_form.getValue('u_impact');
	var urgency = g_form.getValue('u_urgency');

    if ((impact == '1') && (urgency == '1')) {
		g_form.setValue("u_piority", '1');
    }
	else if((impact == '1') && (urgency == '2')) {
		g_form.setValue("u_piority",'2');
    }
	else if((impact == '1') && (urgency == '3')) {
		g_form.setValue("u_piority",'3');
    }
	else if((impact == '2') && (urgency == '1')) {
		g_form.setValue("u_piority",'2');
    }
	else if((impact == '2') && (urgency == '2')) {
		g_form.setValue("u_piority",'3');
    }
	else if((impact == '2') && (urgency == '3')) {
		g_form.setValue("u_piority", '4');
    }
	else if((impact == '3') && (urgency == '1')) {
		g_form.setValue("u_piority,'3');
    }
	else if((impact == '3') && (urgency == '2')) {
		g_form.setValue("u_piority",'4');
    }
	else if((impact == '3') && (urgency == '3')) {
		g_form.setValue("u_piority",'5');
    }


}

 

 

BTW, I wasn't sure if you had a typo for the 'u_piority' variable. 

 

Cheers

View solution in original post

2 REPLIES 2

James Chun
Kilo Patron

Hi @Community Alums,

 

Try the following instead:

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }

	var impact = g_form.getValue('u_impact');
	var urgency = g_form.getValue('u_urgency');

    if ((impact == '1') && (urgency == '1')) {
		g_form.setValue("u_piority", '1');
    }
	else if((impact == '1') && (urgency == '2')) {
		g_form.setValue("u_piority",'2');
    }
	else if((impact == '1') && (urgency == '3')) {
		g_form.setValue("u_piority",'3');
    }
	else if((impact == '2') && (urgency == '1')) {
		g_form.setValue("u_piority",'2');
    }
	else if((impact == '2') && (urgency == '2')) {
		g_form.setValue("u_piority",'3');
    }
	else if((impact == '2') && (urgency == '3')) {
		g_form.setValue("u_piority", '4');
    }
	else if((impact == '3') && (urgency == '1')) {
		g_form.setValue("u_piority,'3');
    }
	else if((impact == '3') && (urgency == '2')) {
		g_form.setValue("u_piority",'4');
    }
	else if((impact == '3') && (urgency == '3')) {
		g_form.setValue("u_piority",'5');
    }


}

 

 

BTW, I wasn't sure if you had a typo for the 'u_piority' variable. 

 

Cheers

Astik Thombare
Tera Sage

Hi @Community Alums ,

 

The problem in your client script is indeed caused by the "Unexpected constant condition" error. This happens because you're using single quotes (') for field names and double quotes (") for string comparisons. In JavaScript, single quotes are used to define string literals, while double quotes can be used for both strings and variable names.

Here's the corrected version of your script:

 

 

 

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
    if (isLoading || newValue === '') {
        return;
    }
 
    if ((u_impact == '1') && (u_urgency == '1')) {
		g_form.setValue('u_piority' == '1');
    }
	else if((u_impact == '1') && (u_urgency == '2')) {
		g_form.setValue('u_piority' == '2');
    }
// ... rest of the logic with corrected variable names ...

 

 

 

 

 

if you are extending table from task table then name of fields should be impact not u_impact and same for priority and urgency

 

Thanks,

Astik