- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 03:13 AM
How to remove or disable an option for a field dependent on another field for a certain group?
In the incident field, there are three fields: Incident closure category, Incident closure category type and incident closure category item.
Incident closure category type is dependent on Incident closure category.
I need to add an option for Incident closure category and that option will be available for one particular group.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 11:22 PM
Hi Swarna,
I tried this on my OOB instance, Subcategory field for Incident table, that field is dependent on Category field.
If you want to add some options for Incident closure category, would that mean it will have its particular set of category type too?
Here I have created a Category,and 2 dependent subcategory and the following script displays the category only for members of particular group when a new record is being created:
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.isNewRecord()) //to stop value from changing once the form has submitted.
{
g_form.removeOption('category','test_cat');
if(g_scratchpad.group_name) //from previous display BR
{
g_form.addOption('category', 'test_cat','Test Cat');
}
}
}
Please mark as correct/helpful if this helps! 🙂
Thanks
DR

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 03:20 AM
Hi Sawrna,
You can try roles instead, check the below link
Please mark helpful if it helps !
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 04:58 AM
Hi Swarna,
if you just want to add a category, you can use the following scripts:
Step 1: Create a display Business rule with script as. Place the below script between function templates in script body.
g_scratchpad.group_name= gs.getUser().isMemberOf('PASS GROUP NAME HERE');
Step 2: Create on load client script as such:
function onLoad() {
if(g_scratchpad.group_name)
{
g_form.addOption('field name', 'your_option_value', 'Your Option Label');
}
}
Please mark as helpful/correct if this helps! 🙂
Thanks
DR
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 06:40 AM
Thanks Debopriya.
But the field Incident closure category type is dependent on Incident closure category.
If we do add option here in thsi case, it isn't working. Did you test this code in your personal instance? I guess it won't work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2019 11:22 PM
Hi Swarna,
I tried this on my OOB instance, Subcategory field for Incident table, that field is dependent on Category field.
If you want to add some options for Incident closure category, would that mean it will have its particular set of category type too?
Here I have created a Category,and 2 dependent subcategory and the following script displays the category only for members of particular group when a new record is being created:
function onLoad() {
//Type appropriate comment here, and begin script below
if(g_form.isNewRecord()) //to stop value from changing once the form has submitted.
{
g_form.removeOption('category','test_cat');
if(g_scratchpad.group_name) //from previous display BR
{
g_form.addOption('category', 'test_cat','Test Cat');
}
}
}
Please mark as correct/helpful if this helps! 🙂
Thanks
DR