Microflow after multiple deletes / delete selection
Can one build a microflow after multiple deletes? For example: Suppose I have a class Course with multiple Trainees and I would like to show the number of Trainees in a data grid. Since I have many Courses every day, my list of Courses is huge and thus in order to cut on performance use whenever this grid is being called, I store this value, instead of using a virtual attribute. Now suppose I also have a data grid of Trainees (per course) and due to a mistake need to delete the majority of Trainees, let's say 23, of a particular Course. I assume this means my Course will be updated 23 times, but I don't want it to be updated 23 times, only once. Is this possible? If so how?
I don't know how or when you store the number of trainees of a course. I assume you do this using an After Commit and After Delete event. In this case you probably want to update the information every time it changes. So instead of using events, you need to manually update the information.
So create a microflow to delete the selected trainees. In that microflow also do the calculations to update the Course with the correct amount of trainees, after deletion.
Create a button with a microflow passing the course and the list of trainees that needs to be deleted. No change the course object by iterating over the trainee list and remove the trainee from the reference list but set the refresh to no. After the iteration commit the course object and do the refresh there. Then the list only gets updated once.