Showing results for 
Search instead for 
Did you mean: 
Advocate II
Advocate II

How to set Gallery.Selected to the just-added SP list Item that was created via a PowerAutomate call (and returns the new Item ID)

How do I accomplish the equivalent of

          Set(Gallery1.Selected, Lookup(Gallery1,ID=NewItemID))

so that when I create a copy/clone of the Gallery.Selected item, the Gallery.Selected gets changed to that just-created item.


Here's the scenario:

I have a Screen with a Gallery (pulled from a SP list) and Viewform of the Gallery.Selected item.

There's a Clone button on that form (circled in yellow) 



When that Clone button is clicked, in CloneItem.OnSelect calls PowerAutomate which creates a copy of that record and returns the ID of the new record just created.  That all works just fine.


What I can't get it to do is change the Gallery1.Selected to "repoint" to the new record.  Here are some of the things I've tried:

  • Refresh() does pick up the new record but doesn't change Gallery.Selected
  • Gallery.Default Lookup() has been suggested,  but this had no effect.    ScanRequests is the SP List that populates Gallery1, NewItemID is a numeric value returned from the PowerAutomate cloning call.  (I hardwired its value to for testing)
    • LookUp(ScanRequests,ID=NewItemID)
  • Gallery.Default Filter() has been mentioned but I don't want to eliminate all other records.   
  • I saw Navigate() suggested, but a) I'm already on the screen I want to be on, it doesn't appear to set anything.

So after a new record is added to the Sharepoint list, how can I get the Gallery to shift its Selected value to the newly created record?


How do I accomplish this:  Set Gallery1.Selected = true where ID=NewItemID?


If you need me to "say more about what you're trying to do", please be specific about what additional information you need.  

Super User
Super User


In this case (since you are creating the record outside of PowerApps in PowerAutomate) you will need to first refresh the datasource in order for PowerApps to see it.

Then you will need to utilize the Default property of the Gallery to select the record.  The key thing to keep in mind is that the record you LookUp in the default MUST match the signature of your Items property of the Gallery.

So, if your Items are simply the datasource, then you can use a straight lookup in the Default.  If you are altering the items in any way in the Items property, then you will need to alter the record equivalently in the Default.  

Ex. if you Drop a column in the Items property, then you must Drop that same column in the Default in order for the selection matching to occur. 


Also, sometimes (although it seems to be resolved now) the Attachments column creates a conflict that causes the match to no can be dropped in both the items and the default.


I hope this is helpful for you.

Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
Advocate III
Advocate III

You should be able to do it using a Variable.


When your SP list returns the new ID, use Set(yourVariable,theNewID)

Set the Default property of the Gallery to Lookup(yourDataSource, ID=yourVariable)

The only other thing may be to force the first gallery item to be selected on first use (as is the default anyway in the background for a gallery) - so you could initally set your variable to something like Set(yourVariable,First(yourDataSource).ID) when the screen is first used or somewhere else appropriate.


Thanks for your suggestions.  I  am anlready doing the Refresh() after returning from the W/F call.


Do I have the syntax correct for Gallery1/Default?


                 where ScanRequest is the data source, NewItemID is a numeric variable holding the ID of the record just created.   No quotes, no brackets?  Just this text?     

I'm wondering if it's a problem with the attachment column, even if I don't have any documents attached?


Or maybe the problem is the variable is numeric? 





I would try to wrap the NewItemID in a Value call just to see if maybe that will fix it. ("Value(NewItemID)") You can highlight NewItemID in the editor and it should tell you the type. For ID it would need to be a number no text. I'm not sure what you have but worth a quick check for sure.


The second thing you can do is save a local copy of the last item that you cloned using clearcollect function. You can do this when you patch a new record.






            param1: value,
            param2: value,

            param3: value,





This would allow you to set the item to First(LastLogin) or look that item up by First(LastLogin).ID.

Yes that's the right syntax for the Default property.
As Scoozi mentions below just check that the NewItemID is the correct data type (which it should be if it's assigned directly from and after the SP list call to create a new item)?

Like it? please click the Thumbs Up button!
Problem Solved? please click the Accept as Solution button to help other Community members find the answer as well!

Helpful resources

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.


New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (1,742)