Retrieve and return object NOT list

0
In a Microflow I want to get an object from the database and then return THAT object (not the list). While I could iterate through the list and re-build the object, that seems like a huge waste. Is there a better way?
asked
9 answers
0

I think you're mixing things up in what you're saying – you say you want “the entire object” but you also say you want all the rows. Each row is an object. You're using a data view, which can only show a single object (one “row”). If you want to show the entire list of objects, you need to use a widget that can display a list of objects, such as a list view, data grid, data grid 2, etc.

 

Edit: To further explain the difference, here's an example:

 

In our domain model, we have an entity called “Car” with the attributes “Brand”, “Model and “Price”.

A user logs into the application. He creates a new Car in the database, a Ford Focus for €27,000.-

This ford focus is one object of the entity Car. 

Now 9 other users add a car and we do a retrieve of the entity “Car” in a microflow.

We now get a List of objects that contains all 10 cars in the database. If we want to show those in a page, we need a widget that can show a list of objects on each row. 

answered
3

If you have a list that retrieved from database and you want to change + commit one object in the list you can try to use list operations. For example you can find an object with a value condition in the list with Find operation. 
You can find more information at here : https://docs.mendix.com/refguide/list-operation/

answered
2

Hi Bill,

In the microflow  in Retrieve activity(from database) select the ‘First’ radio button instead of ‘All’. And  in the Xpath mention your condition for which object it should return. 

 

Hope this helps !

answered
1

Eline,

Thank you.

OK, so my terminology (among other things) is messed up. I did not realize Data View ()DV) was for a single “row.” Your explanation helps me understand why DV wants an object. (row=object)

 

I was trying to use a widget (Tab and Tab Name) that requires that it be inside either a DV or List View. The List View format does not give me the results I need so I was trying to put it inside the DV. So if DV is for a single object (row in my terminology) then it will not work either.

 

Bottom line is that it sounds like (using correct terminology) there is no way to return an entity as an object from a Microflow.

answered
0

Hi Vignesh,

Unfortunately I want ALL the items, not just one. I want to pass the entire object with all the rows.

 

 

answered
0

Hi,

 

You can try to achieve this is using custom Java Action instead of Mendix Loop Iteration to update the records. 

answered
0

Krishnaraj,

I do not want to update anything but I need all the rows in the entity to be returned as an object. AND I would prefer to do it without code (e.g. Java).

 

 

answered
0

If you know the criteria for your single Object, you could do a retrieve in a microflow using XPath constraints to uniquely identify it, then use the First option from the range to just get a single object you can return from the microflow and use in your DataView.

https://docs.mendix.com/refguide/retrieve/#332-range

Does this solve your problem?

answered
0

In this example, the "Retrieve" action fetches a single object based on the specified constraints, and the Microflow ends without further actions, effectively returning the retrieved object. Make sure that your constraints are set up in such a way that they uniquely identify a single object. By the way and driver's license is not a problem now, just on fake id took immediately and inexpensively, and do not need to take 3 months of tests. If the constraints could potentially return multiple objects, you may need to refine them to ensure a single object is retrieved. By following these steps, you avoid the need for iterating through a list and rebuilding the object, making your Microflow more efficient and straightforward.

answered