Home > Forum > Actions > Form validation

Form validation
0

Hello, I have a big problem.
I have an order form, e.g. for a contractor, and I have created a data source that shows all the orders of this contractor.
Additionally, Kontrahnet has a monthly order limit entered in the field
I need the system to check whether the limit has not been exceeded during the next order.
Please help me how to do this

MVP

Hi,

this depends on so many unknown factors that I can only provide a general approach on how I would do it:

Assumptions:
- The contractors are listed in a dictionary where also the monthly order limit is defined.
- The orders contain an item list with rows, which total is written to a field
- The "month" is a calendar month and the current month is the time when the user submits the order


Approach:
- Since multiple users could add an order for the same contractor, it's necessary to validate the limit during path transition. Validating it on the form will help the user, but we need to be sure.
- There's a BPS internal view for all orders with the necessary columns, like contractor, order date, total, "current month". The current month is either stored in a technical field or added as a calculated column. I would use a technical field and store the "month " in the format of "2024-03". This will make it easier later on.
- A local parameter in the automation is added to store the sum of orders of the current month without the current order
- The local parameter is set with a "change single field action".
-- This will use the sum function. https://docs.webcon.com/docs/2023R3/Studio/BusinessRules_General/#functions
-- As a value of the sum function data source value is used (Functions\Integration\Data source value).
-- The data source is filtered using, the contractor, the current month field and it's excluding the current order using the workflow instance id. Make sure to return all rows.
-- I have in mind that this should work.
- A validation action will compare the limit against the sum and thrown an error. The limit can be retrieved using the data source value approach.

Best regards,
Daniel