The CreatorCon Call for Content is officially open! Get started here.

onsubmit client script with ajax ... stop submission

ggg
Giga Guru

I am trying to stop submission of a form if there are no recs in the related list.

i have an on submit client script with ajax call.

the ajax call returns the correct value,

but the submission is not halted.

the form closes and we go back to the list.

is it possible to do this via ajax?

if not, how?

1 ACCEPTED SOLUTION

ggg
Giga Guru

I am able to accomplish my requirement in another way:

In the ui action (server) Submit button I determine if the submit can go forward.

If not,

I use gs.addInfoMessage() to add a message to form;

set a status to "failed";

action.setRedirectURL(current).

this does the job.

View solution in original post

9 REPLIES 9

appreciate the help ...

getXMLWait() is not available for scoped apps which i have.

docs say you must use getXML() ... but ... getXML() is asynchronous ... that is probably why my return false does not make the form stay on the form but returns to the list view (submits the form)

my goal here is to stop submission of a form is there are no related recs (user has not added one)

so I need to get the number of related recs from a client script at the time of submission.

might there be another way to accomplish this?

Can we have an update of this code. Since, the getXMLWait() is depricated ? Thanks. 

Rajshekhar Pau1
Kilo Guru

Hi,

Could you please share your client script and script include both for understanding how you have done it? It would help us to understand and advise you.

Hope this helps.
Mark helpful or correct based on impact.

Thanks.

use the script entered by Aromola above, but do it in a scoped app.

let me know if it works.

ggg
Giga Guru

I am able to accomplish my requirement in another way:

In the ui action (server) Submit button I determine if the submit can go forward.

If not,

I use gs.addInfoMessage() to add a message to form;

set a status to "failed";

action.setRedirectURL(current).

this does the job.