"Update One by One" Mode Fails to Trigger Workflow in a Collection After Record Update

* Describe the bug

In workflows (post action event), when an “Update Record” node is created, there are two update modes available: “Update in a batch” and “Update one by one.”

According to the documentation on update modes:

Update in a batch: Updates all eligible data at once, offering better performance when dealing with large amounts of data. However, the updated data will not trigger other workflows, and audit logs will not be recorded.
Update one by one: Updates data sequentially, allowing the updated data to trigger other workflows, and ensuring that audit logs are recorded. This mode is typically suited for a small number of records, as using it for large data sets may result in performance issues.
According to the documentation, in order to trigger a workflow on the updated record, I should select the “Update one by one” mode in the update record node. However, this is not happening.

In a workflow triggered by an update to a collection (performed through the UI), I created an update node to update my leads collection with “Update one by one” selected. While the lead updates successfully, the lead’s workflow does not execute.

* Environment

  • NocoBase version: v1.3.22-beta.20240918092631
  • Database type and version: PostgreSQL 15
  • OS: Ubuntu
  • Deployment Methods: Docker Swarm
  • Docker image version: nocobase/nocobase:latest

* How To Reproduce

  1. Create two collections:
  • Opportunity Collection:
    Fields: Opportunity ID, Deal Value, Lead ID (reference to a lead), Status (e.g., “Open,” “Closed-Won,” “Closed-Lost”)
  • Lead Collection:
    Fields: Lead ID, Lead Name, Lead Score, Last Deal Value
  1. Set up a workflow triggered by an update to the Opportunity Collection:
  • Trigger: When the Status field of an opportunity is updated.
  • Action: Add an Update Record Node to update the Last Deal Value field in the Lead Collection based on the Opportunity’s Lead ID.
  • Set the Update Record Node to use the “Update one by one” mode.
  1. Create another workflow in the Lead Collection:
  • Trigger: When the Last Deal Value is updated.
  • Action: Update the Lead Score field based on the Last Deal Value.
  1. In the UI, update an opportunity’s Status to “Closed-Won” in the Opportunity Collection to trigger the update workflow.

Expected behavior

  • The Last Deal Value field in the Lead Collection should be updated.
  • The workflow in the Lead Collection should be triggered, and the Lead Score field should be refreshed based on the updated Last Deal Value.

Hi @edsonbmelo , could you please reproduce it on our demo?

Sure! Here is the demo link:
https://a_2u6ofmpo8uz.v7.demo.nocobase.com/

The Lead Score Rule:

  • When the “total deal value” is 0, the score will be C.
  • When the “total deal value” is between 0.01 and 10,000.00, the score will be B.
  • When the “total deal value” is greater than 10,000.00, the score will be A.

image

image

The “Refresh lead score” workflow is responsible for applying this rule, and as you can see in the screenshots, it is working correctly.

I also created an Opportunity collection and a workflow called “Refresh lead total deal value”. This workflow updates the “total deal value” of the associated lead when the opportunity status changes to “Closed-Won”.

The PROBLEM:

In the screenshot below, you can see that the lead’s “total deal value” was updated to 6,000.00, but the score is still A when it should be B based on the rule.

This problem happens in an API call and in a many-to-many relationship when you have the sub-table with “allow add new” toggled. If I call the NOCOBASE API, it doesn’t launch the related workflow

“Update one-by-one will trigger workflow”, this means to trigger collection workflows, not post-action workflows. Post-action workflow will not be triggered from any workflow nodes.

1 Like

@mytharcher Thank you for explaining this. I tried what you said, and it worked perfectly.