corebos icon indicating copy to clipboard operation
corebos copied to clipboard

Workflow triggers on change that is not actually a change

Open Luke1982 opened this issue 2 years ago • 2 comments

I have some code that updates the duedate on a salesorder. Sometimes, the code is triggered because a time changed, but the date has not. Even then, the code will trigger a save on the salesorder, updating the duedate to the same one as it already was.

I also have a workflow in place, that should run when the duedate changes. Now that workflow runs when the duedate is 'touched', even when it does not change. So for instance, the code could update a field that is set to 2022-10-27 to that exact same value, still triggering the workflow.

Could we change that? So that the workflow does not only check if the field is touched but also if it actually changed?

Luke1982 avatar Oct 17 '22 09:10 Luke1982

what I understand is that you have one workflow that triggers correctly and updates the duedate then another workflow has a "has changed" condition to detect if the duedate has changed and this second one is triggering even when the duedate update is identical.

first I looked at the code and see that the condition is not equal, so it shouldn't be triggering the "has changed": https://github.com/tsolucio/corebos/blob/master/data/VTEntityDelta.php#L154

then I created the two workflows as I understand and it seems to be working for me: the "has changed" event is not triggered if the update is the same value.

image

image

The tag is added only when I really change the duedate

Let me know

joebordes avatar Oct 29 '22 22:10 joebordes

Your description is almost correct: I don't have two workflows: I have some custom code that updates the SalesOrder duedate and a workflow that should respond on that update. I see the code you reference, and you're right: the update shouldn't trigger the workflow. Maybe some leading or trailing space messed up the comparison in hasChanged. Thanks for the update, we could close this until I investigate further.

Luke1982 avatar Oct 31 '22 09:10 Luke1982