Restrict values of a choice field based on its current status
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2016 09:54 PM
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
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 10:27 AM
Can you post the onChange client script you have. I can edit your code and post it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 10:34 AM
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 11:10 AM
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);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 11:21 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-09-2016 11:02 AM
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