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-08-2019 12:47 PM
Yes I got the info message but choice is still visible. You can try the same in you instance in your free time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 12:52 PM
Hi,
Configure the dictionary and if this field has dependent value, remove that only then it will work.
And ensure that you are using the value and not the label in the removeOption.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 04:38 AM
Create a Display Business Rule that determines if the logged in user is a member of the Service Desk Group.
populate g_scratchpad.isServiceDeskMember as true or false
in your onchange client script of the subcategory field here is pseudocode:
if category is windows
if g_scratchpad.isServiceDeskMember
addOption(Files)
else
removeOption(Files)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 07:17 AM
After thinking on this some I would think it be easier to leave the dependence and use an onsubmit client script to prevent users from saving the record if they are not in once of the Service Desk group and they choose the subcategory of File/folder restore request instead of trying to hide it.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-08-2019 12:48 PM
I will agree with you Brain. With the conclusion "If there is a dependent value, then addOption() and removeOption() will not work as expected."