The CreatorCon Call for Content is officially open! Get started here.

Onsubmit script for variable set in catalog client script

SK36
Tera Contributor

hi

Can anyone help me with the sample script of onSubmit for variableset's variable. I just want to show one alert by using the script.

 

Any help would be appreciated.

4 REPLIES 4

Gunjan Kiratkar
Kilo Patron
Kilo Patron

Hi @SK36 

You can simply create catalog client script as below:- Select proper Variable set, UI type and applies.

GunjanKiratkar_0-1668151061551.png

 


Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy

Hi thanks for the solution. but my question is,  variable set has a variable and it has true or false value. based on true or false value , I need to put alert.

how to do that?

Hi,

 

You can try below script:

 

if(g_form.getValue("your_variable_name") == "true") //put your variable name here
alert("Put your alert content here"); // Alert that you want to pop when value returned is true
else
alert("Put your alert content here"); // Alert that you want to pop when value returned is false

 

I hope this helps

 

Regards,

Kamlesh

Hi @SK36 

 

You can writedown as below :-

function onSubmit() {
if(g_form.getValue('variable_backend_name')=='true'){
alert('if True');
}else 
alert('If False");
}

Please Mark My Response as Correct/Helpful based on Impact
Regards,
Gunjan Kiratkar
2X ServiceNow MVP
Community Rising Star 2022
Youtube : ServiceNow Guy