With the PreSaveAction function we can perform our custom validations on the client side before committing data to the SharePoint.

In this function we must return either true or false according whether we want proceed with save or not.

But what if our validations are asynchronous? with JSOM and REST you always work asynchronously. How can I return true or false based on my asynchronous checks?

As far as I know, we only have workarounds:

Workaround 1: asynch=false ... is deprecated

Workaround 2: trick the onclick handler ... replace the handler with a custom function and then execute the original handler as a callback ...

Do you know any fully JSOM/REST solution?


In normal JavaScript programming you would want Promises... but SharePoint is not programmed to handle them, it wants a True/False from the PreSaveAction.

So the #3 workaround is to stall your code and make it wait for the async outcomes (which can be all Promises) with something brutal like while(!asyncDone);

I say stick to Workaround #2: Wait async query in PreSaveAction

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.