web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to set Gallery.Sel...
Power Apps
Unanswered

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)

(0) ShareShare
ReportReport
Posted on by 292

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) 

MelissaReed_1-1605013863021.png

 

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.  

Categories:
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @MelissaReed 

    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 occur...it can be dropped in both the items and the default.

     

    I hope this is helpful for you.

  • Wayne_A Profile Picture
    113 on at

    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.

     

  • MelissaReed Profile Picture
    292 on at

    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?

               Lookup(ScanRequest,ID=NewItemID)

                     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? 

                   

     

     

     

  • Scoozi Profile Picture
    64 on at

    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.

     

    ClearCollect(LastClone,

        Patch(YourDB/List,

            Defaults(YourDB/List),

            {

                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.

  • Wayne_A Profile Picture
    113 on at

    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!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 352 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 323

#3
Mohsin Ali Profile Picture

Mohsin Ali 226

Last 30 days Overall leaderboard