corebos
corebos copied to clipboard
Workflow triggers on change that is not actually a change
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?
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.
The tag is added only when I really change the duedate
Let me know
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.