Hello,
I’m using “GET” to capture all list items that have a ‘canceled’ status. Then adding a “Send HTTP Request to SharePoint” to capture the associated list comments, for those items. When my FLOW runs, it only outputs the items that actually have comments and ignores the other canceled items. I wish to send an email containing ALL canceled items with their associated comments and display N/A, if no comments exist. Can someone please advise what steps I might be missing here and how I need to adjust my FLOW? I’m very new to Power Automate, so any assistance, especially with screen shots is appreciated.
Thank you,
MKT
Solved! Go to Solution.
Here is a flow that grabs all comments for a SharePoint List and sends them as an email.
The body of the email consists of the SharePoint item ID followed by the comments, if any:
Here is the high-level flow:
Staring with Get items, and initializing variables:
(2) Apply to Each loop - for each SharePoint list item, get the comments using a SharePoint REST API:
Use Send HTTP request to SharePoint to get the list item comments:
_api/web/lists/getbytitle('Managers List')/items(@{items('Apply_to_each')?['ID']})/Comments
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
Store the comments in a compose action. Note the comments are returned as an array.
Compose action:
@{outputs('Send_an_HTTP_request_to_SharePoint')?['body/d/results']}
Now check to see if there are any comments :
length(outputs('Compose_Results'))
Yes, true condition - there are comments:
No, false condition - there are NO comments:
Finally the send mail action:
Hope this provides some guidance.
Ellis
Adding a summary screen shot of entire flow:
See the following post: Get Microsoft Lists Comments using Flow
Ellis
Thanks Ellis, I am able to get the comments. My problem is figuring out how to output items in an email that don't have comments, along with those that do.
Thanks,
MKT
Here is a flow that grabs all comments for a SharePoint List and sends them as an email.
The body of the email consists of the SharePoint item ID followed by the comments, if any:
Here is the high-level flow:
Staring with Get items, and initializing variables:
(2) Apply to Each loop - for each SharePoint list item, get the comments using a SharePoint REST API:
Use Send HTTP request to SharePoint to get the list item comments:
_api/web/lists/getbytitle('Managers List')/items(@{items('Apply_to_each')?['ID']})/Comments
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
Store the comments in a compose action. Note the comments are returned as an array.
Compose action:
@{outputs('Send_an_HTTP_request_to_SharePoint')?['body/d/results']}
Now check to see if there are any comments :
length(outputs('Compose_Results'))
Yes, true condition - there are comments:
No, false condition - there are NO comments:
Finally the send mail action:
Hope this provides some guidance.
Ellis
Great solution! I'm running into a problem though: Comments are returned in a massive "blob" (HTML?). I tried to fix it by using a "Convert html to text" action in my flow, but got the same result...
When the "@" Mention is used, the comments return with jibberish.
This was sent to @James Shew and it comes back as @mention{0}
Thank you! That helped!
Thanks Ellis, This worked like a charm.
When I run this I get the first 100 or so list ID's comments but I have a sharepoint list with ~300 items. Seems like its only picking up the 1st page in the HTTP request. Is there a way of getting it to look at the entire list? Regards Gerry
Hi @Gezza ,
By default, the Get items action only returns 100 items.
For your case you can increase a setting called the Pagination threshold to 500:
See also:
https://alextofan.com/2019/08/22/how-to-get-more-than-5000-item-from-sharepoint-online-in-flow/
https://www.tachytelic.net/2020/04/many-ways-get-sharepoint-items-power-automate/
Ellis
THanks again Ellis,
Changed the Get Items>Top Count to 5000.
Now picks up all items
Champion!
Cheers Gerry
PS Also changed the pagination settings for get items to pagination on and threshold 5000.
@ekarim2020 - Good Morning, I am having some issues with using this as I'm new to Automate and feel this is way too complicated beyond my expertise - I only have a grasp of basic basics.
Do you have any scope code I could copy and paste into my clipboard in Automate please and just tweak this to my Microsoft List and use it to extract the comments?
Sorry this is beyond cheeky! 🙂
Hi @pigsinblankets ,
The solutions in this post do use some advanced concepts ☹️. There isn't going to be a general template or code that can simply be copied and pasted. You will need to know how to enter expressions and basic JSON knowledge.
Please create a brand new post for your specific issue and we can take a look. Please include describe what you are trying to achieve and post any screen shots of the current flow you are working on and where you are stuck.
Regards,
Ellis
Hi @ekarim2020,
I believe I've copied your flow exactly with some changes to the HTTP request to match my site and list and testing posting comments to a channel in teams. Screenshot below:
The flow can't seem to get past the condition and throw this error
Error: Action 'Condition' failed
Error Details: Unable to process template language expressions for action 'Condition' at line '0' and column '0': 'The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'. Please see https://aka.ms/logicexpressions#length for usage details.'.
Screenshot below:
Any ideas?
Hi @ChristianDias ,
Please show the expression and runtime output of the Compose Results action.
Ellis
User | Count |
---|---|
100 | |
37 | |
26 | |
23 | |
16 |
User | Count |
---|---|
132 | |
52 | |
48 | |
36 | |
24 |