- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 02:38 PM
I have a category and a list of subcategories on our incident table. The category should only be visible if there is a value of true on an external user field. What is the best approach to accomplish this?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:28 PM
HI @Community Alums ,
I trust you are doing great.
Here's a script that will achieve this functionality:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
// Assuming the field name of the custom true/false field is 'external_user_field'
// and the internal name of the category field is 'category'
var externalUserValue = g_form.getValue('external_user_field');
if (externalUserValue === 'true') {
g_form.setDisplay('category', true); // Show the category field
} else {
g_form.setDisplay('category', false); // Hide the category field
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 11:47 PM
Hi @Community Alums
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 05:33 AM
Hi Kai,
It sounds like your solution is close to what I am trying to do. OOB there are some category options in the category/subcategory fields. These should show on the incident form when the user is not external. We have added a checkbox field 'external_user' that if checked we want the category field to only give one option.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-05-2023 03:19 PM
thought so.
You can use g_form.removeOption to strip all the categories you want to remove one by one.
or a more efficient way would be to remove all options, and just add back the one you want to keep.
something like this as an onChange script
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var user = g_form.getReference('caller_id',extUser);
function extUser(user){
if (user.u_external_user == 'true'){ //change field name as required
g_form.clearOptions('category');
g_form.addOption('category','external_user','External User'); //change category to match the one you want to retain. Syntax is 'field', 'value', 'display name'
} }
}
you would then replicate that as an onLoad script for when the record loads.
rules apply as mentioned above, if you change the user to a 'non external user' - the category list will be gone until you hit save and the page re-loads.
if that helps or has answered your question, please click the corresponding button 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 06:28 PM
HI @Community Alums ,
I trust you are doing great.
Here's a script that will achieve this functionality:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
// Assuming the field name of the custom true/false field is 'external_user_field'
// and the internal name of the category field is 'category'
var externalUserValue = g_form.getValue('external_user_field');
if (externalUserValue === 'true') {
g_form.setDisplay('category', true); // Show the category field
} else {
g_form.setDisplay('category', false); // Hide the category field
}
}
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2023 11:21 PM
Hi @Community Alums ,
Create a scripted UI Policy to check if the user is external or not (you need some verification on the form). Based on this, your UI policy action should be category field visible set to true.
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 11:47 PM
Hi @Community Alums
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Best regards
Anders
If my answer has helped with your question, please mark my answer as the accepted solution and give a thumbs up.
Best regards
Anders
Rising star 2024
MVP 2025
linkedIn: https://www.linkedin.com/in/andersskovbjerg/