Have you ever played with the Power Apps Gallery first value in the Power Apps Display Form control? Not at all?
Well, In this Power Apps tutorial, we will discuss how to Set Gallery First Item in Power Apps Display Form.
I recently had a client request where I needed to set the gallery first item in the Power Apps Display form. I used the steps below to do this in Power Apps.
Also, Read: Power Apps Modern Link Control [Detailed Tutorial]
Set Gallery First Item in Power Apps Display Form
Here, we will see how we can set the Gallery first item in Power Apps Display Form.
- A Power Apps Gallery Control (left side image) and a Power Apps Display Form Control (right side image) are seen in the screenshot below. One Power Apps Screen contains both controls.
- Instead of displaying a blank form when I start or run the app, the Power Apps Display form will show with values for the gallery’s first item.
- Here, I have used a SharePoint list as a Data source connector. The image below represents the SharePoint list (Lead Management) having with various columns like:
- Last Name = Single line of text
- First Name = Single line of text
- Job Title = Single line of text
- Industry = Choice
- Company = Single line of text
- Business Phone = Number and so on
Now, follow the instructions below to achieve this needs:
- First, we will create a Power Apps Collection on the App’s OnStart property. And then, create a Context Variable that will hold the default value. This is often done on App start as well.
OnStart = ClearCollect( colLeadManagement, 'Lead Management' ); Set( varDefaultValue, First(colLeadManagement) );
- ClearCollect = Power Apps ClearCollect function eliminates every record from a collection. And then includes a new set of records in the same collection
- colLeadManagement = Provide a Collection name
- ‘Lead Management’ = Provide SharePoint List name
- varDefaultValue = Specify the name of the Context variable
- First(colLeadManagement) = This will return the first item from the collection
- Next, select the Power Apps Display Form and set the variable to its Item property as:
Item = varDefaultValue
varDefaultValue = Specify the Context variable name that you have created in the App’s OnStart property
- Now, select the Next arrow icon (>) from the gallery and apply the code below on its OnSelect property as:
OnSelect = Set( varDefaultValue, GalLeadDetails.Selected )
GalLeadDetails = Gallery control name
- That’s what it does in Power Apps Canvas app. Now Save, Publish (Publish this version), and Close the app.
- Play the app, and you’ll see that the Power Apps Display form has information on the Gallery’s initial item record.
This is how to set gallery first Item in Power Apps Display form.
Moreover, you may like some more Power Apps and Dataverse tutorials:
- Create Multiple Tabs in Power Apps Form [Lead Management Apps Example]
- Power Apps Modern Tab List Control [Everything in Detail]
- Power Apps Modern Badge Control [Complete Guide]
- Power Apps Modern Progress Bar [Detailed Guide]
- How to Visualize Model Driven Data in Power BI
- How to Get Dataverse Created by in Power Automate
- Power Apps Patch Error: The type of this argument ‘Attributes’ does not match the expected type ‘Record’.
In this Power Apps tutorial, we discussed how to Set Gallery First Item in Power Apps Display Form. Also, we saw how to create Power Apps Collection in Power Apps Canvas app.
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com