- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 12:35 PM
Hello.
When a new incident's form is shown (via the Incidents > Create New module), I'd like to obtain the following behavior:
1) when category is set to A or B (let's use letters for an easier description), clear the Service value AND set it as mandatory;
2) when category is set to C or D, clear the Service value but NOT set it as mandatory.
These point's behavior is also required when category is changed from one value to another.
In order to accomplish that, I have implemented a UI Policy with trigger "Category is A or B" and the related true and false scripts, but the observed behavior is that the Service field is cleared and set as mandatory only when category changes from A to B through one of the case 2 values, BUT NOT when category is changed from A to B directly.
Can someone please provide some advice?
Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 12:58 AM
Hello.
Eventually I've solved the issue.
The points below describe the action I've taken.
- I inactivated the UI Policy (Active=false), as it appears not be needed any longer and
- I updated the 1st OOTB row of the onChange Client script as follows:
from if (isLoading || newValue === '' || g_form.isNewRecord())
to if (isLoading || newValue === '')
I hope that what above may help other developers.
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 12:47 PM - edited 03-09-2023 12:48 PM
Hi,
Sorry, your post is a bit confusing, but you've said that you want to clear the Service value AND set it mandatory when the category is A or B. So you're accepting both A and B. Thus, it will only clear the Service value AND set it mandatory when that occurs, which means it would only happen from any other selection than A or B. Not A to B or B to A as you've "accepted" both of those in your scenario.
Please add a bit more information if I'm missing something?
If you're wanting that whenever it's set to A do 'x' and B do 'x', then you may want to see if you have access to the "changes to" operator instead as that would evaluate it changing to it and then executing.
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 01:12 PM
Thanks Andreas, you've perfectly got the point (that is: whenever it's set to A do 'x' and whenever it's set B do 'x').
Unfortunately, the "changes to" operator is not available in the UI Policy Conditions (I hoped it'd have been there), therefore the option you suggested does not appear to be feasible.
Do you have suggestion about how I can have that "change to" behavior?
Thanks.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 01:20 PM - edited 03-09-2023 01:22 PM
Hi,
You can instead use an onChange client script on the category field and then use something like:
if (newValue == 'x' || newValue == 'y') {
g_form.clearValue('field_name');
g_form.setMandatory('field_name', true); //or false, whichever you need
} else if (newValue == 'a' || newValue == 'b') {
g_form.clearValue('field_name');
g_form.setMandatory('field_name', false); //or true, whichever you need
}
You'd want to use the server values not the label values for the x,y,a,b and adjust the script as needed. Please adjust as needed 🙂
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 12:46 AM
Thanks Andreas.
FYI, I already developed an onChange Client script like the one you suggested, but it appears to work only after the first Save of the incident, but not on the new incident's form.
I also tried commenting the OOTB script's first rows, that return in case of a new record, but this made the Service to be cleared after that first Save too (even if the category wasn't changed).
Any other suggestion?
Thanks.