CE1568 - Need help in using input options in a data view

0
I am creating a page, where I am trying to simulate/populate the values for attributes for an entity even before creating the instance of entity. So all the input variables are now inside the Data set and after I added all the attributes, I keep getting these errors. In the documentation, it refers to create objects, for displaying the instance data, I m trying to collect data, to dynamically populate values in the page and later then create object.Pls advice on how to handle this error.
asked
1 answers
0

Hi Pruthvi,


The important point here is that input variables/data set parameters are not the same as attributes of the entity shown by the Data View.


If the Data View is configured for an entity, the widgets inside that Data View need an object instance of that entity as their context. Until that object exists, Mendix has nothing to which those input values can be bound.


So I would structure this as:

Page
  └─ Data View
       └─ Entity: MyEntity
            ├─ Input 1 → MyEntity/Attribute1
            ├─ Input 2 → MyEntity/Attribute2
            └─ Input 3 → MyEntity/Attribute3

Recommended approach

Create the object before displaying the Data View.

For example:

New/Create button
      ↓
Microflow
      ↓
Create Object (MyEntity)
      ↓
Set initial/default values
      ↓
Show Page
      ↓
Data View receives MyEntity object

Or, if the page itself needs to open directly, configure the Data View with a microflow/nanoflow data source that creates and returns the object:

DS_NewMyEntity
    |
    +-- Create Object MyEntity
    |       ├─ Attribute1 = default value
    |       ├─ Attribute2 = default value
    |       └─ Attribute3 = default value
    |
    +-- Return MyEntity

This is the same pattern Mendix uses when a page needs to display a newly created object before it has been committed. The data source can create the object and return it to the Data View.


If the intention is not to create/persist the object yet, another option is to use a non-persistable entity as a temporary form object. Populate that object with the user's input, and only create the persistent entity when the user clicks Save.


So I would not try to populate the Data View's entity attributes through input variables before an object exists. First provide a context object, then bind the input widgets to its attributes.


Also, if by “data set” you mean the Data Set parameter used by a widget/report, that's a different concept from the Data View's context object. In that case, the exact configuration would depend on the widget you're using.


Hope this helps.

answered