Client Script - g_form.addOption() and g_form.removeOption()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2019 05:03 AM
I want to add an option 'Files' under choice list of 'Subcategory' field. But this option should be visible to only Service Desk group when they select 'Category' as Windows. Since there is a dependency, I am not able to get the value 'Flies' in 'Subcategory' using g_form.addOption() method.
If I am creating 'Files' under choices of 'Subcategory' making 'Windows' as dependent value then it will be visible to all. But my requirement is, it should be visible to only Service Desk group members. Even I am not able to remove that option using g_form.removeOption() method.
Any suggestions?
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-07-2019 12:27 PM
Did you get this info message?
g_form.addInfoMessage('inside scratchpad loop');
If yes, then check if you are using the actual choice value and not the label. check what is the choice value configured for that label by right-clicking the subcategory field and click on configure choices and check the value of the choice "File/Folder restore request" and place that in this below code.
g_form.removeOption('subcategory','File/folder restore request CHOICE VALUE');
Mark the comment as a correct answer and also helpful once worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 05:28 AM
i have been trying to do this on my instance as well and get the same result as Ganesh.
If the subcategory is dependent and has the values in the database the add / remove option does NOT work.
so i tried removing them altogether from the table and adding in script, that does NOT work.
so I tried an onLoad script and that does NOT work either.
does anyone actually have this WORKING?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 06:19 AM
If this field is dependent then it will not work. Need to remove that and have to try it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 06:35 AM
right.
but ganesh's requirement is to have the DEPENDENT field added / removed depending upon the user's security group membership.
trying to figure out how to accomplish HIS requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 06:43 AM
You should remove dependent in dictionary and manually handle it through client script.