I implemented a worklfow sending emails with roles without identities. It works as following:
getting all roles
by loop:
get identities for each role
if the role has not assigned identities => send an email with role info
I would like to improve it in order to send one email with all roles without identities at once. I proceeded as following:
Define a variable1 before the loop
Define a second variable2 within the loop to concatenate the role id with the variable1.
However, it doesn’t seem to be possible since I’m getting the initial variable1 value. Thus, I would like to know if it’s a limitation or if I’m not using it correctly. Thank you
What you are trying to do isn’t possible with your approach of using loops.
Once you set a variable using Define Variable, you can’t modify the variable. You can only create a new variable, which may reference the previous variable. Your loop is actually creating several new variables that will each individually contain the value roles: {role name}. However, you cannot reference these variables outside of the loop. When you reference defineVariable1.roles in your email, the value will still be roles because your loop can’t modify it.
The other problem is that loops are asynchronous. Steps that come after the loop cannot reference steps inside of the loop.
The only way I see to solve your use case in Workflows is to implement synchronous recursion, which would allow you to pass the list of roles and also pass a value that appends the name of each role upon subsequent invocations of the recursive workflow. This is a tricky concept to understand, but it should be feasible.