Solution for stopping a catalog item to be submitted when one particular field is showing on portal

Snowman15
Tera Expert

Hi all,

 

I am trying to find a solution for stopping a catalog item to be submitted when one or more fields shows on the front end form. Not sure what can be done eg. to grey out request button, or to hide request button when that field shows upon other previous selections or something different I didn't think of, I am open to suggestions.

 

Many thanks

9 REPLIES 9

Hello @Snowman15 

Create onSubmit client script and use if condition using g_form.getValue()

If yes

return false;

 

Hope this will help you

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Thanks

@Harsh_Deep I tried that, didn't work. The "request" or "submit" button it's a widget, so not sure can be done via client script only?

Vishal Birajdar
Giga Sage

Hi @Snowman15 

 

May be you can try like this...

 

Field will show up when particular value selected means there should have onChange client script.

1.So in onChange client script for that particular code set scratchpad value to true

e.g., g_scratchpad.value = true;

and for others set g_scratchpad.value = false;

 

2.You can use scratchpad value in onSubmit client script to stop submission

 

/* write below code in your form */

if(g_scratchpad.value == true){
return false;
}else {
return true;
}

 

Hope this helps...!

Vishal Birajdar
ServiceNow Developer

I know one thing, and that is that I know nothing.
- Socrates

@Vishal Birajdar I tried that, didn't work. The "request" or "submit" button it's a widget, so not sure can be done via client script only?

Mohan Mallapu
Kilo Sage

@Snowman15 

You can use the catalog onSubmit Client script, Do your validations in the client script and use 'return false'  to stop submitting the form submission.