How to retrieve an attribute over association in a Microflow

Hi Experts,    I am a beginner with Mendix and am seeking your help / suggestions for my below scenario with Microflows.  Please provide suggestions on how to retrieve the value in my Microflow OR will I need to adjust the domain model to fit this?  Scenario: I have a ‘Budget’ entity with below attributes   - Annual spending in USD (decimal) - User Entered   - Annual spending in local currency (decimal) - Calculated with microflow I have a ‘CurrencyConversion’ entity with below attributes   -Currency (EUR, CNY, JPY etc)   -ConversionRate (decimal 0.9, 7.5, 101.5 etc) 'Budget' and 'CurrencyConversion' are associated with 'Budget_CurrencyConversion' association and One 'CurrencyConversion' object is associated with multiple 'Budget' objects On Budget screen, user enters/ picks value for    -Annual spending in USD (decimal)    -Currency (EUR, CNY, JPY etc)  Value for Annual spending in local currency will be calculated using a microflow Annual spending in local currency = Annual spending in USD * (ConversionRate associated with Currency selected in Budget screen) NOTE: Currency is on CurrencyConversion and related to Budget with Budget_CurrencyConversion association How can I obtain the ConversionRate in my microflow? Please provide inputs to achieve the same and thank you for your help!! Thanks Madhavi
1 answers

In your domain model your Budget/Localamount has a microflow Calc_LocalAmount. That will look something like this:

The retrieve is over association $Invoice/Invoice_Currency.

The CreateDecimal is:

if($Invoice/Amount!=empty and $Currency!=empty)
then $Invoice/Amount*$Currency/ConversionRate
else 0

On the budget screen, change your LocalCurrency-dropdown to a Reference- Selector. As On-change-action of that selector save set Save, with ClosePage to No.

See this example page: Whenever you change the selected local currency, the object gets saved and the AmountInLocalCurrency gets recalculated.

This is all happening server-side. More efficient and performant would be to do this client-side, setting the onchange to trigger a nanoflow, but that’s another story...