Home > Forum > Actions > Edge case in order of operations

Edge case in order of operations
0

MVP

Hello community!
I'm facing a challenge for which i don't see any solutions, maybe You will be able to find it.

Use case:
User registers new form (parent), to that form, he needs to register additional forms (children).
It's 2 level tree childrens are leafs, they can't be parents.

On those children forms, there are validation rules, which depends on data from the parent form, and a path [Validate] which checks for required fields.
To make sure that children forms are filled properly - when I'm moving the parent form to further steps I'm invoking that [Validate] path on all childrens to make sure, that data is filled correclty.

It works almost perfectly, but there is an edge case.
When user registers parent form, then children forms and moves parent to further steps - no problems.
When user registers parent form, then children forms, and edits field on parent form which is used to validate children forms - validation rule passes even when it shouldn't.

From what I've read here* it seems that 'On path' automations are executed before form values are saved into the database.
So I'm executing that [Validate] path before data is updated with new value. I can't really move it to 'On entry' of next step, because the next step might be dynamic - I'm using 'Previous step' configuration path target.

Any ideas what could i try here? :)


* https://community.webcon.com/posts/post/pending-in-transaction-vs-pending-after-transaction/347/3

MVP

Hi Maks,


there could be one option for your case, even so it's not ideal. In some cases I've chosen to use dirty reads. This will read data which will be written to the database in another transaction.


https://www.sqlshack.com/understanding-impact-clr-strict-security-configuration-setting-sql-server-2017/
SELECT * FROM LockTestDemo WITH (NOLOCK)

Most of the time this is really bad, but if you are sure, that the data won't be changed in any other way in the parent form, then this could help you out.
You would use the "WITH (NOLOCK)" hint in the child workflow validation action to access the data of the parent form.

You will have to test it, whether this actually helps you.

Best regards,
Daniel

MVP
In reply to: Maksymilian Stachowiak

Thanks Daniel, Paweł for responses, I'm still not thinking about transactions as a standard troubleshooting, so i didn't even considered it yet.
Really interesting idea, unfortunately it seems that saving happens later - WITH (NOLOCK) didn't helped here.

I'm not using any form rules here, although using 'Current path' with 'On Entry' looks promising it requires setting it on every possible step which is something i'm trying to avoid.
This will make further development and maintenance harder, as I'll have to remember it's configured in X places.

Hm, one last idea would be to trigger the child validation not in path trigger but in the onentry trigger.
I know that I had to move some actions to it, so that I could the access the data with a sql command.

Btw. I what will halten if the validation in the children fails? Will the child workflow be moved to some other step or should it not be possible to save the parent workflow?

If the child workflows would be moved, you could also use a timeout in the step of the parent workflow. Which then triggers the child validation path.

But either idea wont work, if the default save action is used.

Best regards,
Daniel