on submit client script is not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi All,
onsubmit client script is not working
function onSubmit() { var gr = g_form.getValue('action'); if (gr === 'sharing') { alert('Chandan Patra'); return false; // Prevents form submission } return true; // Allows form submission }
Thanks and Regards,
Chandan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Avoid using gr as variable.
what is action here, is it a field name?
Remove return=true; there is no need for that statement.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
@chandan2212 Did this work for you?
Please mark the answer correct/helpful accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
are you comparing correct value for action in your IF
💡 If my response helped, please mark it as correct ✔️ and close the thread 🔒 — this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
onSubmit client script like yours, may not run (or its return false may be ignored) if there's another conflicting onSubmit script, UI policy, or asynchronous logic (such as a GlideAjax call) that causes the form to bypass or override the client script, so check whether, another onSubmit client script exists....then script UI Type is set correctly (Desktop / All) and after that check you’re not using asynchronous calls inside onSubmit (which would allow the form to submit before the callback runs)........
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/