Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

OnLoad based on company need to hide choices of a field on form

Community Alums
Not applicable

Hi All, having a requirement, 

 

Need to hide choices of the 'State' field based on the company selection. 

need to try with onLoad script any suggestions.

 

Thanks.

1 ACCEPTED SOLUTION

Eswar Chappa
Mega Sage

Hi @Community Alums  with an Onload client script  as below you can achieve it, I had used Location instead of Country in the below , I had hided Canceled option in the below example

 

function onLoad() {
if (g_form.getValue('location') == '3e94ed7437d0200044e0bfc8bcbe5d9b') {

	g_form.removeOption('state','8');
	
	}  
}

 

Eswar4_0-1692170766896.png

Eswar4_1-1692170973120.png

 

Cheers, hope that helps  /Eswar

*** Please mark as "Correct" or "Helpful" as appropriate ***

View solution in original post

7 REPLIES 7

Harish Bainsla
Kilo Patron
Kilo Patron

You can use OnChange client script

Eswar Chappa
Mega Sage

Hi @Community Alums  with an Onload client script  as below you can achieve it, I had used Location instead of Country in the below , I had hided Canceled option in the below example

 

function onLoad() {
if (g_form.getValue('location') == '3e94ed7437d0200044e0bfc8bcbe5d9b') {

	g_form.removeOption('state','8');
	
	}  
}

 

Eswar4_0-1692170766896.png

Eswar4_1-1692170973120.png

 

Cheers, hope that helps  /Eswar

*** Please mark as "Correct" or "Helpful" as appropriate ***

Samaksh Wani
Giga Sage

Hello @Community Alums 

 

Provided you the same approach, even after i updated accordingly.

 

As per new community rules, you can mark multiple solution as Accept. it will help future members, to reach up the post.

 

Regards,

Samaksh