0

I have the following "Start and wait for approval" step inside my automated flow:

enter image description here

Then I wanted to send an email containing the Outcome of the "start and wait for approval" + the Comment added by the first user for the "start and wait for approval", as follow:

enter image description here

But my question is why Power Automate will automatically add a "Apply to Each" when we try to reference the Responses Comments, while it will not do the same if we try to reference the Outcome?

Do both need "Apply to each"? or both do not? as they are the same context; one return the comment and the other represent the action taken (Proceed or Pending) in our case?? Any advice?

2 Answers 2

2

Power automate approval action returns the response like below:

{
  "responses": [
    {
      "responder": {
        "id": "4ad30135-cdee-4490-b9ef-1714f4724bb3",
        "displayName": "Ganesh Sanap",
        "email": "[email protected]",
        "tenantId": "2e5fa22e-a7c7-45fe-8cd4-f2d2214593dc",
        "userPrincipalName": "[email protected]"
      },
      "requestDate": "2022-02-17T04:46:54Z",
      "responseDate": "2022-02-17T04:47:26Z",
      "approverResponse": "Approve",
      "comments": "Approval comments added."
    },
    {
      "responder": {
        "id": "4ad30135-cdee-4490-b9ef-1714f4724bb3",
        "displayName": "ABC",
        "email": "[email protected]",
        "tenantId": "2e5fa22e-a7c7-45fe-8cd4-f2d2214593dc",
        "userPrincipalName": "[email protected]"
      },
      "requestDate": "2022-02-17T04:46:54Z",
      "responseDate": "2022-02-17T04:47:26Z",
      "approverResponse": "Approve",
      "comments": "Approval comments added."
    },
    {
      "responder": {
        "id": "4ad30135-cdee-4490-b9ef-1714f4724bb3",
        "displayName": "XYZ",
        "email": "[email protected]",
        "tenantId": "2e5fa22e-a7c7-45fe-8cd4-f2d2214593dc",
        "userPrincipalName": "[email protected]"
      },
      "requestDate": "2022-02-17T04:46:54Z",
      "responseDate": "2022-02-17T04:47:26Z",
      "approverResponse": "Approve",
      "comments": "Approval comments added."
    }
  ],
  "responseSummary": "Approver: Ganesh Sanap, [email protected]\r\nResponse: Approve\r\nRequest Date: Thursday, February 17, 2022 4:46:54 AM\r\nResponse Date: Thursday, February 17, 2022 4:47:26 AM",
  "completionDate": "2022-02-17T04:47:26Z",
  "outcome": "Approve",
  "name": "b0c3824a-b8cb-4f62-9527-ef7a0fe34e3c",
  "title": "Approval - First to respond",
  "requestDate": "2022-02-17T04:46:53Z",
  "expirationDate": "9999-12-31T23:59:59Z"
}

It has responses array within approval action output body which stores the approverResponse & comments from each approver (even when there is only one approver). So, when you try to fetch the comments property, flow automatically adds it inside apply to each loop.

And outcome is the final outcome of the approval action which is outside of responses array. Hence, when you try to fetch the outcome property, flow will not add it inside apply to each loop.

So, if you want to fetch the comments of approver you must use "apply to each" and as you are using "Wait for one response" approval, you can either use approverResponse or outcome, both will give you the same results.

6
  • thanks for the reply.. so even if we have multiple outcomes, for example 2 approve + 1 reject.. those responses will be inside a single string and not inside an array? am i correct?
    – John John
    Feb 17, 2022 at 11:12
  • 1
    Responses can be multiple, but final outcome will be only one. Let's say you use "Everyone must approve" approval with 5 approvers, when all 5 approves, outcome will be "Approve" and if any one from 5 approvers rejects, outcome will be "Reject". But, you can get the response of individual approver from responses array using approverResponse property (check the JSON example given in answer to related the properties). Feb 17, 2022 at 11:35
  • thanks a lot for your useful reply.. but i have these 2 extra question; 1) can we configure how the final outcome will be ? for example can we define that unless 2 or more users reject to have the final outcome as Reject, so if only one user reject to consider the final outcome as approve? 2) second question, how the final outcome will be calculated in case we have custom responses? Thanks
    – John John
    Feb 17, 2022 at 12:43
  • 1
    We cannot customize how the final outcome will be in case we use predefined Approve/Reject and and First 2 approval options. Check this video for more information on Approvals & different types: youtube.com/watch?v=4ZnI0_atYUo Feb 17, 2022 at 12:47
  • 1
    In case of custom responses, you get all the responses in outcome property like: "outcome": "CustomResponse1, CustomResponse2, CustomResponse3". I will suggest you check above video once which covers this scenarios. Feb 17, 2022 at 13:01
0

I was recently building a quick approval system for my org and developed a more polished way of doing this without loops & with better formatting...

enter image description here

Code to copy & control+V paste into a new action menu "My clipboard" section

{"id":"1675f896-3d03-4395-a438-6dac8e39bf6e","brandColor":"#8C3900","connectionReferences":{"shared_office365users":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365users/connections/88b73cab99bd4598bfce9895cb9a47b2"}},"shared_office365users_1":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365users/connections/88b73cab99bd4598bfce9895cb9a47b2"}},"shared_office365":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_office365/connections/shared-office365-67f10a94-c084-4840-baf8-1be9-5c063787"}},"shared_microsoftforms":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_microsoftforms/connections/shared-microsoftform-a6fc78b2-11a3-41b2-bf04-1ebf5cf143c6"}},"shared_sharepointonline":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_sharepointonline/connections/shared-sharepointonl-60d1f27e-bd8b-43f2-a8ad-a7be60200f79"}},"shared_approvals":{"connection":{"id":"/providers/Microsoft.PowerApps/apis/shared_approvals/connections/shared-approvals-39fa7c48-bf13-4c6a-a5cd-45d1-5cdc5d95"}}},"connectorDisplayName":"Control","icon":"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzIiIGhlaWdodD0iMzIiIHZlcnNpb249IjEuMSIgdmlld0JveD0iMCAwIDMyIDMyIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPg0KIDxwYXRoIGQ9Im0wIDBoMzJ2MzJoLTMyeiIgZmlsbD0iIzhDMzkwMCIvPg0KIDxwYXRoIGQ9Im04IDEwaDE2djEyaC0xNnptMTUgMTF2LTEwaC0xNHYxMHptLTItOHY2aC0xMHYtNnptLTEgNXYtNGgtOHY0eiIgZmlsbD0iI2ZmZiIvPg0KPC9zdmc+DQo=","isTrigger":false,"operationName":"Get_responders_and_comments_from_Start_and_wait_for_an_approval","operationDefinition":{"type":"Scope","actions":{"SelectMoreApprovalDetails":{"type":"Select","inputs":{"from":"@outputs('Start_and_wait_for_an_approval')?['body/responses']","select":"@concat('Reviewer: ', item()?['responder']?['displayName'], decodeUriComponent('%0A'), 'Response: ', item()?['approverResponse'], decodeUriComponent('%0A'), 'Comment: ', item()?['comments'])"},"runAfter":{},"description":"Enter the Responses dynamic content from your \"Start and wait for an approval\" action in the From field","metadata":{"operationMetadataId":"fdadb5f3-98e8-40a1-9da1-360477370c9b"}},"RespondersAndComments":{"type":"Compose","inputs":"@join(body('SelectMoreApprovalDetails'), decodeUriComponent('%0A%0A'))","runAfter":{"SelectMoreApprovalDetails":["Succeeded"]}}},"runAfter":{"Start_and_wait_for_an_approval":["Succeeded"]},"description":"Will get each responder & their comments for an action named \"Start and wait for an approval\". If your action name is different, like \"Start and wait for an approval 2\" you need to update the From field of the 1st Select action."}}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.