You are viewing limited content. For full access, please sign in.

Question

Question

Limit LFForm.onFormSubmission to Only Run if There are No Errors

asked on August 12 Show version history

Regarding the onFormSubmission functionality with the LFForm object.

https://doc.laserfiche.com/laserfiche.documentation/12/userguide/en-us/content/process-ex-ref-js.htm?Highlight=handler#onFormSubmission

I know I can run some code at the time of the submission and have something happen based on the submission and what action the user took (that part was added with LF12).  But I'm wondering if there is a way for the code to identify that the form has no errors (and thus the submission will be successful once the code completes) versus if there are errors that will prevent the submission.

The help documentation explains that I can return an error to prevent submission, but that's the opposite of what I'm trying to do, I want to have an if statement or other conditional within the function that only runs the code if the submission is happening without errors.

Is that currently possible?

0 0

Answer

SELECTED ANSWER
replied on August 13

Your workaround is the best option right now. I've added it to my list though, thanks!

0 0

Replies

replied on August 12

Unfortunately I don't think so. onFormSubmission happens pre-validation so your code is expected to do its own custom validation if needed.

 

What are you trying to do during a valid submission?

0 0
replied on August 12

I'm adding a record to a table about what action the user is taking and some other values that showed at that point in time.  Our management prefers it in some places over doing a history of the process or similar built-in functionality.

It's something I'm trying to recreate from the Classic Designer.  In the Classic Designer, I have it running the validation and then counting how many errors show on the form, and only proceeding if there are none.  I haven't found a way to do the same kind of forced validation in the Layout Designer.

I've got a solution that I think will meet my needs.  I've got it checking if the last record in the table matches what I'm trying to add, and only add it if it doesn't match.  That way, the note is added the first time I try to submit, but doesn't add again after I correct errors and try again.  It's not perfect, but I think it'll be close enough for this purpose.

0 0
SELECTED ANSWER
replied on August 13

Your workaround is the best option right now. I've added it to my list though, thanks!

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.