Elderberg Posted May 24, 2020 Report Share Posted May 24, 2020 Hi, See below the code which i've used on a web form submission successfully. I've tested this on the Details page, it seems to work, however, the changes made on the Details page don't get written to the database table. Any advise welcome.. <script> // PREVENT SUBMIT UNLESS VALIDATED document.addEventListener('BeforeFormSubmit', function(event) { event.preventDefault(); //do something before submitting update document.forms["caspioform"].submit(); }); </script> Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted May 28, 2020 Report Share Posted May 28, 2020 Hi @Elderberg, JS snippet looks correct. Perhaps you have some Triggered action which interfere with updated records. If not, you can share a whole snippet, so we could help you to narrow down the issue. Regards, vitalikssssss Quote Link to comment Share on other sites More sharing options...
Elderberg Posted July 29, 2020 Author Report Share Posted July 29, 2020 I've isolated the issue to when i have 2 data pages.. with the update page being the second one. I think the document.forms["caspioform"].submit() is submitting the first datapage (which is a HTML page). Any ideas. Quote Link to comment Share on other sites More sharing options...
Elderberg Posted July 29, 2020 Author Report Share Posted July 29, 2020 Did some reading and testing.. my solution, isn't perfect, it just submits the last form on a page with multiple forms. Note that this counts ALL forms and not just forms with "caspioform" as the ID. var x = document.forms; x[x.length-1].submit(); Quote Link to comment Share on other sites More sharing options...
Vitalikssssss Posted July 30, 2020 Report Share Posted July 30, 2020 Hi @Elderberg, I would like to share a different approach, so instead of using a submit() function I have used the click() function on Submit button to mimic submit event. Also, it is possible to use AppKey of the Datapage in order to submit the particular Datapage if more than one is deployed. <script type="text/javascript"> document.addEventListener('BeforeFormSubmit', function (event) { if (event.detail.appKey == 'XXXXXXXXXXXX') { event.preventDefault(); //do smth before Submit document.querySelector(`#Submit${event.detail.uniqueSuffix}`).click(); } }); </script> Hope it helps. Regards, vitaliksssss Quote Link to comment Share on other sites More sharing options...
Elderberg Posted August 28, 2020 Author Report Share Posted August 28, 2020 Hey thanks.. this is great! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.