Refresh datagrid2 after workflow action is executed

0
I have been scanning multiple threads related to refresh behavior in Mendix datagrid2 and haven't been able to pinpoint a definitive answer on refreshing datagrids post action, unfortunately. The issue I'm facing is I have a datagrid2 (entity backed) and each row contains a link button which executes workflow to change an entity's status (i.e. scheduled to in progress). The workflow executes as expected, but we have to currently refresh the browser in order to see the status change. Would anyone have any reccomendations on how to refresh a datagrid2 without less preferred set timers or forcing users to perform a manual refresh?Thanks all!
asked
5 answers
-1

Hi,

This is a common situation with Data Grid 2 + workflow actions, and the behavior you’re seeing is expected.

The key point is: Data Grid 2 does not automatically refresh when data changes outside of its own context (like a workflow execution).

Why it’s happening

  • Your button triggers a workflow
  • Workflow updates the database (status changes)
  • But Data Grid 2 does not know the data has changed
  • So it keeps showing cached data until a manual refresh happens

Correct way to handle this

Option 1 — Trigger refresh using a context object

You need to introduce a refresh trigger.

Steps:

  1. Create a helper non-persistent object (e.g., PageState)
  2. Use it as the Data Grid 2 datasource context
  3. After workflow execution:
Change object → PageState
Refresh in client = YES

Why this works

Data Grid 2 listens to its context object.

When that object is refreshed:

→ Grid reloads data automatically

Option 2 — Use microflow instead of direct workflow call

Instead of calling workflow directly from button:

  1. Create a microflow:
    • Call workflow
    • Commit changes
    • Return something (or nothing)
  2. From page:
    • Call this microflow
    • Enable:
Refresh in client = YES

Option 3 — Use Data Grid 2 “Refresh on action” (only if applicable)

If your button is configured as a grid action:

  • Enable:
Refresh after action = YES

But this works only when:

  • Action is directly tied to the grid row
  • Not always reliable with workflows

Option 4 — Use nanoflow + refresh object hybrid

If using nanoflow:

  • After workflow call:
Refresh object (context or helper object)

What NOT to do

  • Avoid:
Set interval / timers

  • Avoid forcing:
Full page reload

These are not clean solutions.


Use:

Helper object (PageState) → bound to Data Grid 2

Then after any backend update:

Refresh PageState

This gives consistent and predictable refresh behavior.


Data Grid 2 does not auto-refresh after workflow execution because it does not detect external data changes. The correct approach is to trigger a client-side refresh using a context object or by refreshing the datasource indirectly, rather than relying on timers or manual reloads.


answered
1

This is a common limitation when using workflows with DataGrid2. Workflows run outside of the page context, so the UI is not automatically aware that something has changed. That’s why you only see the updated status after manually refreshing the page.


Because of this, DataGrid2 will not refresh on its own unless something in the page context is updated. Calling a workflow directly from a button does not trigger any UI refresh.


A clean approach is to wrap the workflow call inside a microflow. In this microflow, you trigger the workflow and then refresh something that the page depends on. This could be the main object or a helper object.


If your datagrid is using a datasource microflow, make sure that datasource depends on something you can refresh. For example, a non-persistent helper entity. After the workflow execution, you update this object and use “Refresh in client” so the grid is forced to reload.


This way, you avoid using timers and keep the behavior predictable.


In short, workflows do not trigger UI updates automatically, so you need to refresh the page context (via microflow or helper object) to make DataGrid2 reload.


 If this resolves your issue, please mark it as accepted.


answered
1

SImilar to previous post, I always use a Change Object activity in the microflow, where I change the object that the datagrid2 is working with, and then set that activity to refresh only and not commit of course.

answered
1

Joe,

One other suggestion: Data Grid 2 has a property called Refresh Time (in seconds) that is used to refresh data in Data Grid 2 without any other work required. By default, this setting is 0 which means no auto refresh happens. However, setting it to a reasonable value will refresh the data automatically. This will update the data on your page periodically based on workflow updates.


Hope that helps,


Mike

answered
1

About Option 2 Implementation


This may be happening because the workflow runs asynchronously.


So even if you call it through a microflow and enable Refresh in client = Yes, the grid refresh might happen before the workflow has finished updating and committing the status. In that case, Data Grid 2 would just reload the old value, and the updated status may only become visible on a later refresh.


One possible improvement would be to set the first status change (for example In Progress) before starting the workflow, then commit it and refresh the client. That way, the user may at least see the initial change immediately, while the later workflow updates continue in the background.


Another option you could consider is using a helper/context object to trigger the refresh, since that can sometimes behave more predictably than relying only on a direct refresh after the button action.


So my guess would be that the issue is less about Data Grid 2 itself and more about the timing between the client refresh and the workflow commit.


answered