None option for a drop down

Not applicable

Hi,

How to change the code for the None option to work? The rest of the options are good.

 

1.png

 

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

   var status = g_form.getValue('u_state');
   if(status == 'new'){
	g_form.setMandatory('u_in_progress_status', false);
	g_form.setMandatory('u_resolved_status', false);
	g_form.setMandatory('u_canceled_status', false);
	g_form.setVisible('u_new_status', true);
	g_form.setMandatory('u_new_status', true);
	g_form.setDisplay('u_in_progress_status', false);
	g_form.setDisplay('u_resolved_status', false);
	g_form.setDisplay('u_canceled_status', false);
   }
   if(status == 'in_progress'){
	g_form.setMandatory('u_new_status', false);
	g_form.setMandatory('u_resolved_status', false);
	g_form.setMandatory('u_canceled_status', false);
	g_form.setVisible('u_in_progress_status', true);
	g_form.setMandatory('u_in_progress_status', true);
	g_form.setDisplay('u_new_status', false);
	g_form.setDisplay('u_resolved_status', false);
	g_form.setDisplay('u_canceled_status', false);
   }
   if(status == 'resolved'){
	g_form.setMandatory('u_new_status', false);
	g_form.setMandatory('u_in_progress_status', false);
	g_form.setMandatory('u_canceled_status', false);
	g_form.setVisible('u_resolved_status', true);
	g_form.setMandatory('u_resolved_status', true);
	g_form.setDisplay('u_new_status', false);
	g_form.setDisplay('u_in_progress_status', false);
	g_form.setDisplay('u_canceled_status', false);
   }
   if(status == 'Canceled'){
	g_form.setMandatory('u_new_status', false);
	g_form.setMandatory('u_in_progress_status', false);
	g_form.setMandatory('u_resolved_status', false);
	g_form.setVisible('u_canceled_status', true);
	g_form.setMandatory('u_canceled_status', true);
	g_form.setDisplay('u_new_status', false);
	g_form.setDisplay('u_in_progress_status', false);
	g_form.setDisplay('u_resolved_status', false);
   }
//    if((status != 'new') && (status != 'in_progress') && (status != 'resolved') && (status != 'Canceled'){
// 	g_form.setMandatory('u_new_status', false);
// 	g_form.setMandatory('u_in_progress_status', false);
// 	g_form.setMandatory('u_resolved_status', false);
// 	g_form.setMandatory('u_canceled_status', false);
// 	g_form.setDisplay('u_in_progress_status', false);
// 	g_form.setDisplay('u_resolved_status', false);
// 	g_form.setDisplay('u_canceled_status', false);
// 	g_form.setDisplay('u_new_status', false);
//    }
   
}

 

2.png

 

3.png

 

In the picture you can see the New status is not getting removed when I change the status to None.

 

Regards

Suman P.

6 REPLIES 6

SAI VENKATESH
Kilo Patron

Hi @Community Alums 

To do that You can try this:

 if (g_form.getValue('your_choice_field') == "") {

        //do the following

    }

 

Thanks and Regards

Sai Venkatesh

Not applicable

Hi @SAI VENKATESH,

 

I used this but it didn't work.

 

if(g_form.getValue('u_state') == ''){
	g_form.setMandatory('u_new_status', false);
	g_form.setMandatory('u_in_progress_status', false);
	g_form.setMandatory('u_resolved_status', false);
	g_form.setMandatory('u_canceled_status', false);
	g_form.setDisplay('u_in_progress_status', false);
	g_form.setDisplay('u_resolved_status', false);
	g_form.setDisplay('u_canceled_status', false);
	g_form.setDisplay('u_new_status', false);
}

Juhi Poddar
Kilo Patron

 Hello @Community Alums 

 

For this type of scenario, a UI Policy is the best solution as it requires no scripting and only configuration setup. Please refer to the screenshots below for the complete solution.

 

case 1: when state is new

JuhiPoddar_0-1731130454887.png

 

case2: when state is Resolved

JuhiPoddar_1-1731130545913.png

 

case3: State is in progress

JuhiPoddar_2-1731130663390.png

 

case4: state is cancelled

JuhiPoddar_3-1731130787457.png

 

case5: state is None

JuhiPoddar_4-1731130868534.png

 

Preview Result:

JuhiPoddar_5-1731130967006.png

JuhiPoddar_6-1731131000191.png

and similarly for other status.

 

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thank You

Juhi Poddar

Not applicable

Hi @Juhi Poddar,

 

Of course I can but I don't want to. I am trying to increase my development skill.

 

Regards

Suman P.