Hi, sorry this is so long, I am stuck. I created a multi-stage approval in Power Automate to work through a business process with multiple approvers. The Flow has five 'Start and wait for approval' steps. Each approval step provides approvers the option to log their comments about the step. I have a requirement to log these comments into a running log during each Flow run and I wish to write the comments as history values into a multi-line field in SharePoint along with a time calculation to show how long an approver needed to make their decision. For context, I am attempting to replicate the approach shared by @RezaDorrani in his YouTube video called "Build long running approval flows with Power Automate".
Each of the 5 approvals in the Flow has an 'Update SharePoint Item' step that utilizes the 'responder' for that approval level. During the build, when I add the responder/DisplayName from the apply to each to the update field that will store the history, Flow automatically wraps the approval status item into an 'Apply to each' loop. I am having trouble getting the comment history value to write from any approval beyond the first approval in this Flow because the Update SharePoint Item step in the second approval and beyond cannot access the history value from the previous approval; that history field is not available in the dynamic content since it is part of an apply to each. I attempt to get at the first item in the apply to each array but fail to capture the desired string.
For example, on the technician approval step, I am trying to access the history item from the previous approval step and its apply to each array to write that value to this step's WF_History field by using: "body('Water_doc_approval_Apply_to_each')[0]['WF_History']". This errors out and cannot access that data.
I think I am just not getting how to get at the data that is obviously there in the JSON and it, frankly, is driving me bonkers. Does anyone have an idea how I can access the history field from the previous step's JSON and write it to the current step, and so on? The intent is to take the comments from each approval step and log them into a history field in the SharePoint list.
If it helps at all, I get the following error:
InvalidTemplate. Unable to process template language expressions in action 'Technician_Processing_Approval_Apply_to_each' inputs at line '1' and column '38876': 'The template language expression 'body(Technician_Processing_Approval_Apply_to_each)[0]['WF_History']' cannot be evaluated because property '0' cannot be selected. Please see https://aka.ms/logicexpressions for usage details.'.
Thank you and Happy New Years!
Solved! Go to Solution.
Aha, yes it is possible! Just add a Get File Properties just below each approval so that the item's history is available in dynamic content when you update the SharePoint list for the item's history. 👍
@brego , can you share the screenshot of your flow and point in the screenshot where you facing the issue, to better understand it.
@brego , it looks like issue with the body('Water_doc_approval_Apply_to_each')[0]['WF_History']), there is no such property of the approval responses from approval action, what do you need approver comments?
@annajhaveri thank you for taking a look. I think I understand what you may be pointing out; the WF_History from the Water_doc_approval_Apply_to_each is not available to the Engineer approval step. Do you think it possible to access the WF_History value from the previous approval's Apply to Each?
Aha, yes it is possible! Just add a Get File Properties just below each approval so that the item's history is available in dynamic content when you update the SharePoint list for the item's history. 👍
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Read the latest about new experiences and capabilities in the Power Automate product blog.
At the monthly call, connect with other leaders and find out how community makes your experience even better.
User | Count |
---|---|
26 | |
25 | |
24 | |
22 | |
17 |
User | Count |
---|---|
59 | |
41 | |
36 | |
30 | |
30 |