Hello, I would like to know how to prevent a form submission if amounts for the various lines of costs do NOT match Total invoice field AND how i can build a logical to block this sending + alerting the user sth is bad
Hi there, and welcome to the miniExtensions community!
Could you explain a little bit more about your use case? Is there a specific reason why you’d want your users to enter the total amount as well as the individual expenses?
Your setup could work, and I’ll briefly explain how below, but I would probably suggest a different route:
Instead of having your users enter the total amount manually, you could just ask them to enter the individual expenses and then use a rollup field in the form’s table that sums up the “Amount” field from the table related to the “Invoice Allocation” field. You could then add this rollup field to your form and enable “Save & Continue” mode. This allows for the rollup field to be displayed on the form after the users clicks the “Save & Continue” button and would provide a visual confirmation of the total amount. If the amount is off, your users could then adjust the records in the “Invoice Allocation” field to get to the desired amount. You could also add a checkbox if you wanted your users to confirm that the total amount shown is correct and set that checkbox to required so a form cannot be submitted without first confirming the total amount. I hope this makes sense but please let me know if you need any further details on any of this! I’d be happy to help!
Here's how to make your current setup work
For the sake of completeness, here’s how you could make your current setup work: You’d need a rollup field in the form’s table that sums up the “Amount” fields of the expenses. You could then have a formula field that calculates the difference between that rollup field and the “Amount” field in the form’s table and set up field validation based on that formula field. You would need to enable “Save & Continue” mode for formula and rollup fields to work. This does work but it’s not ideal so I’d recommend the option I’ve outlined above.