I have an object Usergroup in my metamodel with a referenceset to User where users can join the group. I now want to show the name of each group with the amount of users in each in a datagrid on my homepage, so I created the variable Count in my Usergroup object. What is the best way to track all the usercount for each group? Using a microflow to +1 and -1 the count each time a user joins/leaves seems like the obvious choice but maybe there is a preferred, conventional way to track this? Edit: I just found that you can add a microflow to an attribute, can this help with my problem? When does this activate?
Robert van 't Hof
You can model a microflow which you trigger before commit. Then retrieve all the users of the same group excluding the current user, count them, +1 (to add the most recent user) and you get the up to date number of users. You have to exclude the current user because it should work both the first commit as well as the second commit.
You should also model a second microflow which you trigger before delete. Then retrieve all the users of the same group, count them, -1 (to remove the deleted user) and you get the up to date number of users.