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

I'm not talking about addoption or removeoption.  I'm say let everybody see it but then use an onSubmit client script that will not allow them to save if they choose that subcategory.  You can then thought an alert in there to tell them that only Service Desk or Service Desk L2 agents are allowed to use this category.  So taking you original code and placing it inside an onsubmit would look something like this.

var cat = g_form.getValue('category');
 
if(cat == 'Windows'){
   if (g_scratchpad.grp==false){
        alert("Only Service Desk and Service Desk Level 2 are allowed to use the subcategory of " + g_form.getValue('subcategory'));
        return false;
	  
   }

ggg
Giga Guru

I am going to try a summary here of options to resolve this issue:

1) keep cat and subcat as is and use onSubmit to catch the Security Group requirement. I know in my work this would not fly because managers would say do NOT show something you should not be able to select.

2) remove the dependency from the database configuration and accomplish it in client scripts.

If you remove the dependency, then onChange of category you cna hide the subcategory. the remove does not work when there is dependency.