- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2023 06:26 AM
Hi All,
I want to work with field 'State' in Incident form:
Currently no matter which state is chosen, I can choose every available option - 'In progress', 'Resolved' and so on
I want to change choices in 'State' field depends on currently chosen value in field 'State', for example:
Currently I have state 'New' and I should have, from 6, only 3 options available to change the state:
For example only: Active, On hold, Closed
Do you how can I achieve this?
It would beeasier if it would depend on other field but here everything happens in the same field so that is why I am wondering
Thanks in advance for help!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2023 08:48 AM
Hi Kasia,
You will want to do this with a client script I think, you may need just an onload script OR an onload and an onchange.
if (newValue == 'In Progress' ) {
g_form.removeOption('state', 'Resolved');
//Repeat above line for other states to be removed
}
You can also use the below to add options back in, but be mindful that if the option is already in the list, I think it adds a duplicate.
g_form.addOption('state', 'Pending');
The example I first added uses "newValue" (because it would be an onchange client script) but if you were using an onLoad client script you would want to replace that with g_form.getValue('state')

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-13-2023 08:06 AM
Hi Kasia,
A switch statement is structured like the below. switch(value_you_want_to_check) and then each case is a value you are checking for.
switch(newValue){
case '1':
g_form.removeOption('state', '5');
g_form.removeOption('state', '6');
break;
case '2':
g_form.removeOption('state', '1');
g_form.removeOption('state', '7');
break;
}
You should find that as a switch statement OR an if statement the client script should run every time you change the state field, even if you change it multiple times before saving.
When you save the form and the page refreshes, your choicelist will reset. So you will need an "onload" client script to run and remove any options that shouldn't be there.