Retrieve Action with Get or create functionality - Mendix Forum

Retrieve Action with Get or create functionality

2

In many microflows, a single Retrieve action isn’t enough. We often need a “get or create” pattern:

  1. Retrieve an object
  2. If nothing is found, create a new object
  3. Continue the microflow/nanoflow using the retrieved or newly created object


To handle this, I frequently build a reusable SUB_GetOrCreate microflow/nanoflow per entity type. However, to better support the DRY principle and reduce repetitive logic, I would like to suggest enhancing the Retrieve action to optionally support GetOrCreate behavior in one action.


Suggested enhancement

In the retrieve action, give developers an option to have "Get Or Create" functionality so that if retrieve returns no object, Mendix automatically creates a new instance of the selected entity with the assigned attribute values.


We can accomplish this by adding a checkbox in the Retrieve action configuration:

[_] Create if not found


When enabled: Retrieve action UI expands (similar to the Create Object action) to allow setting attribute values for the newly created entity.


This would streamline common patterns, reduce number of steps in flows, and make microflows/nanoflows easier to read and maintain.

asked
0 answers