cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

retrieve a single list item for SharePoint Get Item

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Dual Super User III
Dual Super User III

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().

screenshot.png



-------------------------------------------------------------------------
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

10 REPLIES 10
Dual Super User II
Dual Super User II

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

Dual Super User III
Dual Super User III

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.



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

@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()?

Untitled.jpg

Dual Super User III
Dual Super User III

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().

screenshot.png



-------------------------------------------------------------------------
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

Anonymous
Not applicable

@Pstork1 that was what I needed.  Thank you!  On to the next error...!  Smiley Very Happy

Anonymous
Not applicable

@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?

Dual Super User III
Dual Super User III

The dynamic content screen filters things and that can sometimes be an issue.  What kind of field are you trying to retrieve?



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

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.

 

SagarS_0-1594719187266.png

Could you help please? Thank you.

Dual Super User III
Dual Super User III

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.



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

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.

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

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!

Top Solution Authors
Users online (3,671)