- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 08:24 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2025 01:03 AM
this onSubmit is for catalog item?
Please share some more details, what are you trying to validate in onSubmit
Why not have the validation on change of your field/variable?
also check these links
How To: Async GlideAjax in an onSubmit script
How to validate before onSubmit in Mobile/Service Portal
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 11:17 PM
Hi @陳立東
calling "g_form.submit()" within the onSubmit script would essentially trigger the submission again, leading to an infinite loop or unexpected behavior. If you need to programmatically submit the form based on certain conditions, you should avoid calling g_form.submit() directly inside the onSubmit client script. Instead, you can rely on the default form submission behavior. Use return false to prevent submission if needed, or rely on form validation to control submission behavior.
function onSubmit() {
if (g_form.getValue('field_name') == 'some condition') {
alert('Condition met! Submission will be prevented.');
return false; // Prevent submission
}
return true; // Allow submission
}
I hope my answer helps you to resolve your issue, if yes please mark my answer helpful and correct.
thank you
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-14-2025 11:49 PM
I think so,but g_form.submit() is not wroking.
why calling "g_form.submit()" within the onSubmit script dos not trigger the submission now?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2025 12:58 AM
can you share your script here rather than image?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2025 01:03 AM
this onSubmit is for catalog item?
Please share some more details, what are you trying to validate in onSubmit
Why not have the validation on change of your field/variable?
also check these links
How To: Async GlideAjax in an onSubmit script
How to validate before onSubmit in Mobile/Service Portal
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader