Client Script - g_form.addOption() and g_form.removeOption()

Community Alums
Not applicable

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?

22 REPLIES 22

Community Alums
Not applicable

Yes I got the info message but choice is still visible. You can try the same in you instance in your free time.

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.

ggg
Giga Guru

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)

Brian Lancaster
Tera Sage

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.

 

Community Alums
Not applicable

I will agree with you Brain. With the conclusion "If there is a dependent value, then addOption() and removeOption() will not work as expected."