Updating an attribute in another entity!

0
Hello, I am creating a small app for managing stores and employees working in stores. Its a 1-* relationship between both entities Stores and Employees. I have a field in my Stores entity called “countOfEmp”. My plan is for this field to get automatically updated “hopefully through a Microflow” whenever I add/edit/delete an employee in the Employee entity. Please advice on how to best approach this?
asked
6 answers
2

Hi Mohamad Saleh,

 

For this, you can add an 'After Commit' and 'Adelete' event handler on the 'Employee' entity and can add the logic in that microflow to update the count of employees for the associated store. So, in this way, whenever you commit or delete the employee object, the configured event handler microflow will be triggered.

 

You can refer to mendix docs as well: Event Handlers | Mendix Documentation

Thanks,

Sonam

answered
0

Thanks. What kind of activities should I include in logic? See attached

 

answered
0

Thank you, Sonam.

It works great now when adding new employees. It appropriately updates the count whenever I add a new employee. Should I create another workflow to update the count whenever I remove an employee from a specific store? 

answered
0

Still not working, folks!

Adding a new employee will update the count just fine. Deleting an existing employee won’t update the count. Here is what I have so far in my workflow!

answered
0

Thanks Sonam,

Can you please elaborate a little more to this? 

Here is what I have for my store “Retrieve Object”

answered
0

And here is what I have for my list Of Employees “Retrieve” object

 

answered