Hi all, Pretty new to MX, so perhaps it’s an easy one for you. What I’m trying to do is the following: I’ve created a ‘lunch app‘ where I’m currently trying to ensure the receipt costs from the lunch automatically get deducted from the budget from the people who were attending the lunch when I fill in the receipt’s value in the app. What I’ve done so far: Colleagues are able to register for the lunch via a datepicker + reference selector to select their own name and the date when they’ll be attending the lunch, using domain model below: Colleague – Name (String) | 1 – * to Week | 1 – * to EurosAmount EurosAmount – Attribute (Decimal) | * – 1 to Colleague | * – 1 to Week Week – Date (Date and Time) | * – 1 to Colleague | 1 – * to EurosAmount Next to that I’ve created a listview where I’m displaying the names of the registered colleagues (text), their budget in euros (decimal) and 2 different buttons to delete and adjust their budgets. Would be great if anyone could help out on finding the right MF or NF (or other way of working) to get this sorted. Thanks in advance!
Well the first thing you would need to do is set the budget for that week. So you would need your assign budget microflow to do the following:
Create a new Euros Amount object
Present a user with a page where they can pick the ‘week’ object and the ‘Colleague’ object associated with that week
If the User is a ‘Colleague’ as well, you could retrieve the Colleague from the current account and set that association automatically
On the page where you select week, budget, and colleague values, commit and refresh the ‘EurosAmount’ object
So that’s pretty simple to do. That will help you populate your list view of EurosAmount objects like you have shown in your screen shot. You can also write a microflow for your delete button, which should just be a MF that takes a EurosAmount in as a parameter, then deletes that object.
The next thing is to add a receipt, for which you will need to create a new entity Associated with Colleague and Week (both many– to-one like EurosAmount) that has a ‘ReceiptAmount’ attribute. When users click the ‘lunch’ button:
Take the EurosAmount in as an inpuit parameter
Retrieve the Colleague and Week associated with that EurosAmount
Create a New RevieptAmount object and associate it with the Colleague and Week
present a page where users enter this ‘ReceiptAmount’ value
When the user hits ‘save’ call another microflow that subtracts the ReceiptAmount from the EurosAmount budget, which is stored in the ‘Attribute’ value
Commit and refresh the EurosAmount object
So that is a very basic flow to set a budget for users and then decrement it as users enter receipts. There are plenty of delighters to do here, like attaching pictures to receipts, giving users a place to view receipts, or calculating and presenting how much budget is remaining for the week.