cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper II
Helper II

Flow run failed: Unable to process template language expressions for action

I'm running a flow "When an item is created" and it will get the file metadata then "Start and wait for an approval". The result approval result will transfer the file to a designated folder "Approved Submission" or "Rejected Submission". However, I encountered an error.

Unable to process template language expressions for action 'Apply_to_each' at line '1' and column '43604': 'The template language expression 'body('Get_attachments_(Get_attachments_of_approved_item)')?['body']' cannot be evaluated because property 'body' cannot be selected. Array elements can only be selected using an integer index. Please see https://aka.ms/logicexpressions for usage details.'.

 

Here's my flow.

 

11223344

 

 

Here's where the error occur:


Error.png

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User III
Dual Super User III

So my example above uses a different trigger (that's easy to change), doesn't include the approval process (Which can be inserted just above the get item), and isn't conditional based on the outcome of the approval.  But the rest of the process is the same.  Just insert the approval and the condition and then duplicate everything from the Get Item down in the two different branches and point them at the right list.  Its just a slightly more complex version of my sample above.  But the logic is the same.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

15 REPLIES 15
Dual Super User III
Dual Super User III

Which action in your flow throws the error?  Your screenshot is so compressed it really isn't readable.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

@Pstork1 apologies, I already updated the post.

Dual Super User III
Dual Super User III

Take a close look at the Apply to Each loop where the error occurs.  Based on the error it looks like you are adding the body from the wrong action above.  I would also suggest that you get the attachments and add them to an array before you create the item.  Then add the array in the create Item under Advanced. That will make the logic a lot cleaner and keep you from making two passes.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

Hi @Pstork1 ,

 

I trimmed down the flow.

 

After getting the attachment, I added "Create Item" then "Add attachment", my only concern now is I'm getting an error "Action 'Add_attachment' failed"

 

Here's the flow.

 

flowflow

 

Here's the error.

 

Screen Shot 2020-12-03 at 1.23.57 AM.png

Dual Super User III
Dual Super User III

I assume you are trying to add the attachments in the Loop to the body of the item created in the Create Item.  That won't work.  As I said you should process the attachments first to add them to an array and then add the array of attachments in the advanced settings when you create the item.  Or you can probably use the method you are using now, but read the attachments from the variable array you create instead of the item.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

@Pstork1 sorry I just started using SharePoint and Flows a few days ago. Still confused, how do I go about your  instructions - process the attachments first to add them to an array and then add the array of attachments in the advanced settings when you create the item.  Or you can probably use the method you are using now, but read the attachments from the variable array you create instead of the item.


Helper II
Helper II

Hi @Pstork1 here's the revised  flow. It was successful and  didn't encountered any error but it didn't move the attachment to another list. 

 

1122

 

Dual Super User III
Dual Super User III

In the last action you need the file content in the file content field, not the id.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

@Pstork1 I don't see "file content" on the dynamic options.

 

Screen Shot 2020-12-03 at 10.43.28 PM.png

Dual Super User III
Dual Super User III

The actions to get files doesn't always retrieve the content itself because that can be quite large.  There is a specific action for Get Attachment Content.  You need to use it the same way you use Get Attachments.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

@Pstork1 added "Get attachment content" it moved the attachment to the new list. Problem is the file name is showing as a number which I think is the file ID and when the attachment is clicked it downloads a RAR file which can't even be unarchived.

1122

Dual Super User III
Dual Super User III

The logic of your flow is still strange.  You are getting attachments and content and then creating items in a loop based on the number or Responses to the approval?  You'll end up with duplicate items for each approver. Why are you creating multiple items and adding the attachment to each?  Also, when you get attachments its going to return a collection that requires a loop to process.  But you are treating it like a single item.  I suspect that is why you are getting the RAR archive file.

 

Here's what the basic logic flow should be if I understand what you are trying to do.

 

1) An item is created with one or more attachments

2) An Approval is created for that item.

3) Once the item is approved the status is updated.

4) Once updated you need to get the Item again to make sure you have a recent copy

5) Get the attachments

6) In an Apply to each loop Get each attachment content and add the name and ContentBytes to an array

7) exit the Loop

😎 Create the new item 

9) Use another Apply to each loop to add the files stored in the array to the new item.

image.png

image.png



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper II
Helper II

@Pstork1 bear with me and let me explain what I want to happen.

1. A user will add an entry in the SP List "Upload New Document" and include an attachment.

> Custom columns has been created for the details of the document.

2. Once the user clicks "Save" it trigger an approval process, where I will be notified via email to review the document and choose whether to Reject or Approve the submission.
  Condition:

> If approved the entry will move to the "Approved Submission" list including the attachment and include the approver comments.

> If rejected it will move to the "Rejected Submission" list including the attachment and include the approver comments.

3. Once the entry has been moved to each specific list based on the result of the approval, to delete the entry in "Upload New Document"

 

 

 

 

Dual Super User III
Dual Super User III

So my example above uses a different trigger (that's easy to change), doesn't include the approval process (Which can be inserted just above the get item), and isn't conditional based on the outcome of the approval.  But the rest of the process is the same.  Just insert the approval and the condition and then duplicate everything from the Get Item down in the two different branches and point them at the right list.  Its just a slightly more complex version of my sample above.  But the logic is the same.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

View solution in original post

Helper II
Helper II

Thanks got it!

Helpful resources

Announcements
New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (46,944)