I have a SharePoint list that has a single item (always). I'm trying to use Get Item to retrieve the value in a single column so I can update a variable. I don't have the ID of the item. If this were sql I would do a max() function to get a single value. I don't know OData filter syntax and can't quite figure it out.
Solved! Go to Solution.
If your list only contains one item you don't need to do anything particular with Get Items. YOu just need to use First() whenever you want to access one of the fields in the list that is returned. So I have a list with a single line of text field called Color. I do a Get Items to get all the items in the list and then when I want to use Color I put that dynamic content call inside First().
Hi @Anonymous
Get Item has to have the ID
You next best bet is to use GetItems to get all items
and then use for loop and get the column info you need
Regards,
Reza Dorrani
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
If the list never has more than one item then you could just use Get Items and the First() function to address the single record in the list. Get items doesn't require an ID but will always return a collection of records even if its a collection of one.
@Pstork1 Your answer appears to be what I need but I can't figure out how to use it. Here is my get items, I assume I am using the Filter Query, how do I add the Items collection to first()?
If your list only contains one item you don't need to do anything particular with Get Items. YOu just need to use First() whenever you want to access one of the fields in the list that is returned. So I have a list with a single line of text field called Color. I do a Get Items to get all the items in the list and then when I want to use Color I put that dynamic content call inside First().
@Pstork1 I spoke too soon. In the Dynamic Content I see the column I need but when I select "First()" then go back to the dynamic content, the column is gone. Any thoughts?
The dynamic content screen filters things and that can sometimes be an issue. What kind of field are you trying to retrieve?
Hello @Pstork1
When I use first(body('Get_Item')?['Value']) in the expression to initialize a variable, the flow is throwing an error to correct this reference.
Could you help please? Thank you.
When you add the content to the screen before using the first it will add a for each loop. Hover over the dynamic content at the top of the loop and inside the loop. Copy down the JSON that is there. You'll need a combination of that JSON entered manually into the expression tab if the dynamic content filters the value out. Show me those two JSON strings and I'll help you figure out what the right JSON should be.
Oh, that's a nice tip sir. Thank you.
I had renamed 'Get Items' action and was still using Get_Items in the first expression. Your trick gave me the correct JSON name for above action, when I used it, it worked. Thanks again.
Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.
Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!
User | Count |
---|---|
48 | |
32 | |
32 | |
31 | |
29 |