How to hide question choices on a service catalog item

Milan Hrdlicka
Kilo Contributor

I have a service catalog item containing 4 question choices.

I need 2 of these question choices hidden based on current user's logged in role.

The crucial thing is I am unable to check out how to hide thse fields even without the dependancy on a user's role.

I tried this:

g_form.removeOption('value','cym3');
g_form.removeOption('value','cym6');

'value' is question choice's value. I tried this in Catalog client script however it does not work.

I use Madrid instance.

Can anyone please help?

Thanks a lot!

Milan

 

 

14 REPLIES 14

Elijah Aromola
Mega Sage

Make a catalog UI policy for that item that has the following script: 

find_real_file.png

 

You will obviously need to change the roles it is checking for. 

 

Please mark this as the solution and helpful if it resolved your problem.

Allen Andreas
Administrator
Administrator

In addition to the help by Elijah above...you'd want to ensure you are using the variable/field name and then the selection value.

So if I had a field called:

Question - My Favorite Color is What?

Name - fav_color

Selection choices are

Question - Red

Name - red

Question Blue

Name - blue

Then it would be g_form.removeOption('fav_color', 'red');

And then in the run scripts in UI field you see in the above screenshot...if you want this to also work on Service Portal for users, then ensure you select both in that field and not just Desktop.

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

Milan Hrdlicka
Kilo Contributor

Thank you for your replies, but it stilll doesn't work, don't know what I am doing wrong...

 

1.) I tried this in Catalog Client Script - simply tested removing the question choices not based on role (just if it does work on its own at all...) It doesn't work - attaching screen shot with variables.

 

function onLoad() {

g_form.removeOption('pack_type','cym3');
g_form.removeOption('pack_type','cym6');

}

 

2.) tried this in Catalog UI Policy but it does not work, when it comes to "When to apply" I tried"pack_type is anything" so it should be evaluated to true and put the same script as above and it does not work anyway (please see another screen shot with "When to apply" options.

 

I am using Madrid.

Appreciate your help,

Milan

are you testing it on portal ? if yes make sure you have set catalog client script UI Type as ALL.

 

make sure in your catalog client script you have set the value of choices correctly, validate if any space exist in value ?