Restrict values of a choice field based on its current status

srirao
Giga Expert

Hello Experts,

I am trying to restrict the values of a choice field based on its current value. I understand we can use   "Dependent Field" to restrict the values of based on the values of the other field but what I am trying to do here is little different.

I have a field named "Phase" and it has values viz. Concept, Define, Design, Build, Test, Release, Close.

The default value has been set to Concept. When Phase is set to Concept, it should only show Concept, Define and Close and when it is set to Define it should only show Concept, Define, Build and Close.

I am sure this must have been achieved already by your experts.

Appreciate your help.

Thanks

20 REPLIES 20

Can you post the onChange client script you have. I can edit your code and post it.


Sounds exactly what is happening on Change Request form where you can only see the current value and sometimes the next value. Take a look at the Client Script that comes out of the box named: Show valid states values - that might give you the idea on how to make it work!


Michael.Fry



Thanks Michael but I am sorry I couldn't find the "Show valid states values" out of box Client Script.



Do I need to write something like the below one, instead of setDisplay() use removeOption()?



if (newValue == "field") {


  g_form.setDisplay('field', true);


  g_form.setDisplay('ui_action', false);


  g_form.setDisplay('form_buttons', false);


  g_form.setDisplay('form_section', false);


  g_form.setDisplay('related_lists', false);


  g_form.setDisplay('related_list_element', false);



  } else if (newValue == "field_label") {


  g_form.setDisplay('field', true);


  g_form.setDisplay('ui_action', false);


  g_form.setDisplay('form_buttons', false);


  g_form.setDisplay('form_section', false);


  g_form.setDisplay('related_lists', false);


  g_form.setDisplay('related_list_element', false);


My Dev instance is running Geneva, and while I could provide the out of the box code, it calls a script includes, and then that calls another script includes, etc. So you can try what others suggest or try to find an instance where the code is available for you to review and see if you can get working how you need it to work.



Looking through it, it's using the State values 1, 2, 3, 4, etc to limit the available States.


Hi Srirao,



I have modified some changes , hope it will help you.



function onChange(control, oldValue, newValue, isLoading, isTemplate) {


      var onevalue = g_form.getValue('u_phase');



  if (onevalue == 'Concept') {


       


     


  g_form.addOption('u_phase','Concept','Concept');


      g_form.addOption('u_phase','Define','Define');


      g_form.addOption('u_phase','Close','Close');


      g_form.removeOption('u_phase','Test');


      g_form.removeOption('u_phase','Design');


      g_form.removeOption('u_phase','Build');


      g_form.removeOption('u_phase','Release');


     


    }





  else if(onevalue == 'Define'){



      g_form.addOption('u_phase','Concept','Concept');


      g_form.addOption('u_phase','Define','Define');


      g_form.addOption('u_phase','Close','Close');


  g_form.setValue('u_phase','Build');


  g_form.removeOption('u_phase','Test');


  g_form.removeOption('u_phase','Design');


      g_form.removeOption('u_phase','Release');




  }


      //Type appropriate comment here, and begin script below


   


}




Reards,


Harshvardhan



Hit Like/Helpful/Correct if applicable