Unable to set '--Please select a value--' in catalog item variable

Rakesh50
Mega Sage

Hi,

We have a catalog item  "Access" and it has a variable called 'Category' select box type. It has couple of choices instead of 'None' we want to use "--Please select a value--" option. I have created onload script and it is working in native view but portal not setting the value.Please check attached screenshots.

Onload Native view

Rakesh50_0-1696935681005.png

onload service portal - by default it is setting to first choice option instead of '"--Please select a value--"

Rakesh50_1-1696935845959.png

 

can anyone suggest me to resolve this issue?

 

Thanks,

Rakesh T

 

1 ACCEPTED SOLUTION

Hi @Rakesh50 

Try this code

g_form.removeOption('category','');
g_form.addOption('category','', '--Please select a value--', 0); //no spaces for second paramter
g_form.setMandatory('category', true);

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

View solution in original post

9 REPLIES 9

RaghavSh
Kilo Patron

Is the UI type of your on Load client script set to "All" , if not it will not work on portal.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

Hi @RaghavSh ,

UI type already set to all and applies to requested items also true

Voona Rohila
Kilo Patron
Kilo Patron

Hi @Rakesh50 

Can you please share the onload client script you configured.

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Hi @Voona Rohila ,

 

Please check the below code

 g_form.addOption('category', '','--Please select a value--',0);
   g_form.setValue('category','');
	g_form.setMandatory('category', true);