Same helper in 2 sections

0
HiI have a page split into two sections, and in both of them I need the same helper, which is a non-persistent entity that I create when entering the page. I’m trying to load it with a microflow in two DataViews, one in each section, which retrieves the existing helper and creates it if it doesn’t exist. However, each DataView ends up creating its own helper, so I end up with two different helpers. Does anyone know how I can fix this problem?I’ve tried creating two different microflows, and also tried adding a delay to one of them, but nothing worked.
asked
3 answers
2

The issue is that both dataview microflows run in parallel when the page loads, so neither sees the other's object yet. The simplest fix is to not use two dataview microflows at all. Instead, use a single dataview at the top level (wrapping both sections) with one microflow that creates the helper, and then nest your two sections inside that one dataview. Both sections will then share the same helper object through the enclosing dataview context.


If for layout reasons you really cant nest them under one dataview, another approach is to create the helper in a nanoflow before the page opens (pass it as a page parameter), and then use both dataviews with a "context" or "microflow" source that just returns the same object passed in. That way creation only happens once and both dataviews get the same instance.

answered
2

Create a non-persistent Holder and a non-persistent Helper entity. Add a 1- association* from Holder to Helper so the Holder can keep a reference to the single Helper instance.


When opening the page, create one Holder and one Helper, then set the association so the Helper is linked to the Holder (e.g., Holder/Holder_Helper = $Helper). Pass the Holder as the page parameter.


On the page, in both DataViews, do not call a “get-or-create” microflow. Instead, use the association source: select the Helper via the Holder association (e.g., DataView datasource = Holder/Holder_Helper). This guarantees both sections use the same Helper instance and prevents each DataView from creating its own separate Helper.


answered
0

Each DataView with a microflow datasource runs separately. So both DataViews create their own Non-Persistent Entity. That’s why you get two helpers.

Correct Fix :

  1. Create the helper in a microflow.
  2. Open the page from that microflow.
  3. Pass the helper as a page parameter.
  4. Set both DataViews → Datasource = Context (not microflow).

Now both sections use the same helper instance.

Do not use two microflow datasources for the same NPE — that will always create duplicates.

answered