How can i cancel submit in OnSubmit client script based on a asynchronous GlideAjax call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2018 08:13 AM
Hi,
I have a requirement to cancel submit of a catalog item based on a asynchronous GlideAjax call. I am not able to return false from the response function. Previously it worked with a synchronous GlideAjax call as there was no function call.
Please advise.
Thanks in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2018 12:47 PM
Hello Divya,
Can you share your script?
You should be able to cancel the submission by returning false in the onSubmit function.
Take a look at this wiki article - Client Scripts - ServiceNow Wiki
Kind Regards,
Michael
PS - Please mark Helpful, Like, or Correct Answer if applicable.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2018 01:52 PM
I believe the problem is making an AJAX call in onSubmit. Ajax calls are async and Ajax Wait does not work in service portal which means it will make the call to Ajax and keep running even though you did not get your response back from ajax call to say false if it fails. onSubmit will continue working and end things thinking all is good even though your ajax call is off getting you answers.. I was able to find a solution in my case but it is not ideal and I would love to know if someone knows a better way. I had to move the call to an onChange event but I was never really happy with how I got it working. Ajax Wait was a nice thing for this.....
But yes return FALSE in onSubmit will not allow it to continue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-02-2018 02:16 PM
Dear Divya,
Is there is a reason why you are trying to use asynchronous ajax call?
