Solution for stopping a catalog item to be submitted when one particular field is showing on portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 07:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 08:01 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 08:13 AM
@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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 07:38 AM
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...!
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 08:13 AM
@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?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2023 07:44 AM
@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.