Hello Community,
I have the following client requirement I am struggling to solve, and would appreciate some guidance.
At a high level, we have an entity in Dynamics 365, and the user will be filling the form via the Power Apps Portal, and the requirement is to verify a set of 70 fields on the record against the respective field validation rule, only after the record is submitted. I don't need to trigger this check everytime one of the 70 fields gets updated. I only need to trigger this check when the status of the record is updated to Submitted.
I am thinking to use Power Automate for this solution. I am not a developer that writes codes, so hoping to stay away from custom codes (i.e. Azure Functions, etc.).
So, when the Flow is triggered, I need to check the value of a "Code" field on the record (there are 4 different codes: C, R, S, T). For each code, the validation min/max value range for the 70 fields is different. So if the code = C, I need to check the 70 fields on the record against the rules, and if the code = R, I need to check the 70 fields on the record against another set of different rules, and so on. The validation is basically to check if the value entered in the field is within the min/max value range defined in the validation rule for that particular field. Again, depending on the "code", the min/max value range varies for each of the 70 fields. So in total we have 284 combinations.
Also, the requirement says if a field fails the check, I need to update a multi-line text field on the record with some log message, and the message is unique for each field that fails the check. Also, if any of the fields fails the check, I need to flag a checkbox field on the record. The whole idea is that after this Flow is done processing, the user in Dynamics can easily go to the dashboard to review any records having the checkbox field flagged as having a problem so the user can review the record, and the user can look at the multi-line text log field on the record to know which of the 70 fields to examine the data. That's what we are trying to achieve for the client.
I could build out this big Flow logics using one Condition check action for each of the field, but I will end up needing to have 284 such Condition checks, because if each one fails, I need to update the multi-line log field, so I need individual Condition checks. But this would be massive, very time consuming to build. Also, the client would like to be able to easily update the rules in the future, so it's not good to define the rules inside the Flow.
So, I was thinking to create a custom entity in Dynamics 365 to store the rules. So I will have 284 records under this custom entity, each one representing a rule for each field (4 codes x 70 fields = 284 rules).
I can use the "List Records" action in the Flow to fetch the 284 rules, but I am having problems coming up with the logics to dynamically pass the record I am checking in the Flow against the unique one rule from the list of 284. Ideally, I like to be able to use some kind of looping where the Flow would understand and be smart enough to examine the 70 fields from the records against the respective 70 rules from my custom entity list, based on what the Code is.
Does anyone have any insights on how I could achieve this in a more dynamic efficient manner? If there are better solutions to do this without using Power Automate I would be interested to know as well - again I am hoping for a solution that does not require custom codes. Sorry for the long description, but I hope this helps explain the requirement I am trying to solve.
Thank you!