Old Related Bank Record Not Reset When Changing Bank in Workflow

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • brotherlouie
    Junior Member
    • May 2023
    • 24

    #1

    Old Related Bank Record Not Reset When Changing Bank in Workflow

    Hi,

    I’m using EspoCRM 9.1 with the Advanced Pack.

    I have a custom entity called Virman, which has a many-to-one relationship with the Bank entity.

    Here’s my setup:

    When a new Virman record is created, a Workflow updates the related Bank record (for example, adds or subtracts amounts based on transaction type).

    When a Virman record is updated, the Bank record is recalculated.

    When a Virman record is deleted, the Bank record is recalculated again to remove its effect.

    All these actions work perfectly except when I change the related Bank.

    Here’s the issue in detail:

    I create a Virman record linked to Bank A with an amount of 1000 USD.
    → Bank A correctly shows 1000 USD in its total field.

    Later, I edit the same Virman record and change the linked bank from Bank A to Bank B, then save.

    After saving:

    Bank A still shows 1000 USD (it should reset to 0).

    Bank B also shows 1000 USD.
    So both banks temporarily show the same value.

    When I manually click “Recalculate formulas” on the Bank entity, everything becomes correct:

    Bank A resets to 0.

    Bank B correctly shows 1000 USD.

    It seems that formula recalculation or Workflow logic is not automatically triggered for the previously related Bank record when the Virman → Bank link changes.

    Is there any way to automatically trigger recalculation (or a Workflow) for both:

    the old related Bank (to reset its value), and

    the new related Bank (to update with the new amount)?

    Or is there a recommended approach to handle this case when the relation field is changed in Workflow?

    Thanks a lot for your help!
  • victor
    Active Community Member
    • Aug 2022
    • 1027

    #2
    You didn't show what your Workflows look like, but the most obvious workaround in my opinion is to create https://docs.espocrm.com/administrat...ows/#scheduled, which would run periodically on records included in the List Report (which you will use for this Workflow).

    Comment

    Working...