Check object association has only 1

2
My before commit SuperRole microflow gets a list of all ApplicationRole objects saved within the current SuperRole. I need to check to make sure that per Application there is only 1 ApplicationRole selected. I can find the Application through my association. How can I best create my iterator to count all ApplicationRoles belonging to each Application and output a number so I can check if it equals 1?
asked
3 answers
10

From your question I understand that you are trying to make sure that every ApplicationRole of the SuperRole is from a different Application. This is how you do that in microflow:

First create a list of type Application (List > Create). Then loop through the ApplicationRoles (you might need to retrieve them first if you only have the SuperRole object). For each ApplicationRole, retrieve the Application using a retrieve activity (Object > Retrieve). Then, using a list operations (contains) activity (List > List operations) and an exclusive split, check whether the Application is already in the list of Applications. If so, you can break from the loop and return false. Otherwise, add the Application to the list of Applications (List > Change).

answered
3

If I understand the question correctly, the best thing to do the following in the Iterator (that iterates over Application);

  • Retrieve alle Application Roles for the Application
  • Then use another iterator that iterates over these Application Roles
  • In the iterator of for instance Application Role A, try to retrieve a list of Application Roles with similar 'Name' or 'Description' (the attribute should be unique within the Application in the outer iterator)
  • Count the number of Application Roles
  • Then check if this number equals '1'

Good luck!

answered
0

You can retrieve all ApplicationRoles by using a Retrieve activity in the microflow. After that, you can count the number of elements in the resulting list by using an aggregate activity (List > Aggregate). Choose Count as the function in the aggregate. The result is a number that you can compare to 1. This way you do not need to write a loop yourself.

answered