user1358852
user1358852

Reputation:

XPages - trigger validation before executing CSJS?

I have a button which executes some CSJS but before doing so I would like to trigger document validation. I normally validate the document before saving using SSJS and a display errors control. This validation works fine when I press my "Save" button which triggers a save document simple action. Is it possible to trigger this validation before executing CSJS?

Upvotes: 0

Views: 584

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

There are a few options.

You could put the CSJS in the onComplete event of the button's eventHandler (you need to go to the All Properties of the eventHandler, not the All Properties of the button to find onComplete).

You could call the CSJS via the SSJS method view.postScript("myCSJSFunction()").

If you use the CSJS tab for the button, that will always trigger before any submission for server-side processing. It's designed for client-side checking to occur and prevent server-side, e.g. using return confirm("Are you sure?") to check whether a user actually wants to cancel out of a document or delete a document etc.

Upvotes: 4

Related Questions