Display the Microflow Result in a Data View

0
Good Day to you!  I am really scratching my head here, I have sought help by reading the Mendix Docs, I have researched youtube videos, and went through similar questions even trying to follow Larn van de Vries and Eric Tieniber's responses on the following link https://community.mendix.com/link/space/microflows/questions/119258 additionally I even sought help from ChatGPT and the results are not working for me. Essentially I am creating an expense tracker. I have the Entity created [with Attributes Who, When, and Amount(Decimal)] and a persistent entity (CalculateTotal), the over view pages created, and pretty much have the microflow complete. what I am attempting to accomplish is having all of the "Amounts" from the entity shown in the data grid 2 to be auto-summed and shown in a data view with text box at the top of the page. The microflow goes as such: Start (Return type "Decimal"), Retrieve list from expenses database, Create Decimal variable (0), Loop for each item in list & change variable TotalAmount with value $TotalAmount + $CurrentExpense/Amount, after loop i have create object using the persistent entity, end return value $TotalAmount I placed the data view on the page and used the data source to call the microflow. Additionally, ChatGPT is telling me to add a text/label and to bind it to the microflow by typing in the data source 'CurrentObject" however, that is not an option.  I keep getting the following errors: (x2) CE1568 selected page 'expenses_overview_ expects an object of type expenses.calctotalexp', which is not available here CE0552 Microflow 'CalculateAmounts' does not return an object and warnings: (x2)CW4010 Page parameter 'CalcTotalExp' is not used I'm not sure what I am missing here and any help is greatly appreciated!   
asked
2 answers
1

Hi Brice, 

 

It seems like you microflow is returning a Decimal value in a variable.

But your text box is expecting an attribute, which always is part of an entity.

The variable you return in the microflow in the screenshot can not be returned to a page. 

The value you have calculated in the variabel needs to be set in the attribute in the object and you should return the object to the page and select the right attribute for the text box.

 

Hope this helps.

answered
0

Thank you for your reply Vicky! As a Mendix newbie I was still a little confused. I did figure it out working with process of elimination based on your response. I have formulated the following steps in case anyone else has this issue:

1. Domain model has 2 entities, a persistable with the list of attributes shown for data grid 2. A non-persistable with a single attribute for whichever attribute you'd wish to total. I labeled mine "Expenses" & "TotalExpenses" with decimal and 0 stored.

2. Microflow > This microflow does not need a Parameter. Edit (double click empty space) Return Object, Select the non-persist entity

3. Retrieve List from persist entity, no need to select attribute. 

4. Create Variable > For me Decimal with Value 0 - Named 'TotalAmount'

5. Loop ( Each Item In List) and I named mine 'LoopExpenses'

6. Inside Loop, Change Variable, selecting the one created in step 4. for Value reference your variable name + loop name/Amount. For me '$TotalAmount + LoopExpenses/Amount'

7. After Loop, Create Object, select not persist entity, Commit & Refresh, New - Member (your variable), Value: your variable name (for me $TotalAmount) I named my object 'TotalExpenses'

8. End - Value: your created object name, for me $TotalExpenses

Microflow Complete

9. To show in a dataview, select microflow and choose the one you made. it should auto fill out, if it doesn's, drop a TextBox into it. Select the attribute of your non-persist entity. In the "Input Mask" Label: $[Loop name/variable name], for me - Total Expenses: $[CurrentObject/TotalAmount]

 

I hope this helps anyone else in need. 

answered