Hello,
I have a flow which doesn't seem to work correctly all the time and I am unsure what the issue is and why it works sometimes but not other times.
When a response is submitted from an MS Form, this needs to go through an approval process:
1. Responders Manager needs to approve it
2. The Approvers Manager then needs to approve it
3. Then it keeps moving up the chain and asking each approvers manager for approval
However, if the managers job title contains Principal, the Do Until is then completed and it should move onto the next action after the Do Until.
I have had submissions that have worked perfectly and the Do Until has looped round and followed the correct paths.
But, there are also occasions where it doesn't loop back and it moves onto the next action after the Do Until, despite the managers job title not containing Principal.
This is how it is currently set up:
Variable CurrentUserUPN: Type: String, Value: Respnder's Email
Variable LookupUserUPN: Type: String, Value: Variables('varCurrentUserUPN')
Variable Approval Level: Type Integer, Value: 0
Variable Stop: Type: Boolean, Value: false
Variable Chain Log: Type: String, Value:
Variable Last Outcome: Type: String, Value:
In the Do Until:
Increment variable: Name: varApprovalLevel, Value: 1
Get Manager: User (UPN): variables('varLookupUserUPN')
Compose Responders Job Title: coalesce(outputs('Get_user_profile_(V2)')?['body/jobTitle'], 'Unknown')
Compose ManagerEmail: coalesce(outputs('Get_manager_(V2)')?['body/mail'], outputs('Get_manager_(V2)')?['body/userPrincipalName'])
Compose ManagerTitle: coalesce(outputs('Get_manager_(V2)')?['body/jobTitle'], 'Unknown')
Compose ManagerName: coalesce(outputs('Get_manager_(V2)')?['body/displayName'], 'Unknown')
Condition:
Outputs('Compose ManagerTitle') contains Principal Or Outputs('Compose Responders Job Title') contains Principal
true: Set Variable: varStop, Value: true
false:
Start and Wait for an Approval: Assigned to outputs('Compose ManagerEmail')
Condition if equal to Approve
Set Variable: varLastOutcome, Value: Approve
Compose:
concat(
variables('varChainLog'),
if(equals(variables('varChainLog'), ''), '', ';'),
outputs('Compose_ManagerName'), ' - ', outputs('Start_and_wait_for_an_approval_2')?['body/responses'][0]?['responseDate'], ' - ',
outputs('Start_and_wait_for_an_approval_2')?['body/responses'][0]?['approverResponse'], ' - ',
coalesce(
outputs('Start_and_wait_for_an_approval_2')?['body/responses'][0]?['comments'],
'(no comment)'
)
)
Set Variable: varChainLog, Value: outputs('Compose')
Set Variable: varLookupUserUPN, Value: outputs('Compose ManagerEmail')
An example of a run that should have looped back but didn't looks like this:
I would expect this to say 1 of 3.
The true path should always be where the flow completes the Do Until path and the last loop would have a tick on the true path. But the example above, went to the responders manager to approve, which they did, and it carried on past the Do Until. It should have gone to the approvers manager to approve, then loop back and check their manager, who does have Principal in their job title.
Can someone advise if i am doing anything wrong or have a better way of doing this?
thanks