cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Newbie12
Helper V
Helper V

Search and pre-populate form fields in PowerApps

Hi,

 

I have 4 screens in my PowerApps. DataSource is Excel Table.

 

Screen1 contains Gallery tiles of systems, say "Sys1","Sy2","Sy3". When Clicks on any Gallery tile, it navigates them to Sceen2 which contains, instrument summary, also screen 2 contains information about system status [Available,In Use,OOS].

 

When user selects the system that is "Available", it displays 3 buttons on Screen 2 "Signup","Update Status" and "Cancel". When user selects "In Use" or "OOS", it displays only 2 button on screen2 "Update Status" and "Cancel".

 

OnSelecting "Signup" button on Screen 2 user navigates to Screen3, where user can put relevant information,and signup for the instrument. One of the column that is unique in this form "User ID" in text form (ex:john1)

 

When User Selects "Update Status" button from Screen 2, user navigates to Screen4. Where user can update the status of the system. I would like to allow end user to search for their ID and would like to pre-populate the edit form fields.

 

Ex: Let's say John wants to update the Status of Sys1 because he signed up for Sys1.When John clicks on Update Status it navigate him to Screen4, where he can enter his User ID and the fields such Model#,System# will be AutoPopulate for him. The only thing left form him will be to select correct system status from dropdown, and on submitting the button the status field will be populated in Excel Table.  

 

Note I would like to Auto-populate field based on only last Entry by John.

 

I am not sure how to achieve this in PowerApps.

Any help is appreciated!

 

 

27 REPLIES 27

Hi!

Are you using "Patch" Function to update the item?

Yes!

Ok, so, to update an item, just put the "object Item" as a second parameter of Patch formula

 

Continuing with my previous example:

 

 

UpdateContext(
    {
        vLastRecordOfUser: Last(
            Filter(
                Systems,
                Upper('User') = Upper(TextInput1.Text)
            )
        )
    }
)

 

 

You can use the patch Formula, like this:

 

 

Patch(
    Systems,
    vLastRecordOfUser,
    {model: "test"}
)

 

 

I still get a second line entry. I got an error on the first semi-colon so I changed it to a comma and the error resolved. Here's the beginning of my Patch: 

Patch('Yearly Time Management',vLastRecordOfUser;{StandardHours:TextInput5_StandardHours.Text,TargetPercent:TextInput5_Target.Text,DirectLaborHours:TextInput5_Direct.Text, ...

 

Does vLastRecordOfUser need to proceed each column/text field?

Hi!

you are rigth with the commas!

 

you can edit just the columns you need to. How did you "populate" the vLastRecordOfUser variable? before you updates its fields. 

ehr
Helper I
Helper I

Hi!

I populate by adding vLastRecordOfUser.StandardHours as Default in the TextInput fields and my UpdateContext per your example is:

UpdateContext(
{
vLastRecordOfUser: Last(
Filter(
'Yearly Time Management',
Upper(EmployeeName) = Upper(TextInput5_Search.Text)
)
)
}
)

 

And the Patch is as stated above.

dariobois
Resolver II
Resolver II

Hi!

 

Did you try something like this?

 

Patch(
    'Yearly Time Management',
    First(Filter('Yearly Time Management',ID = vLastRecordOfUser.ID)),
	{
		StandardHours:TextInput5_StandardHours.Text,
		TargetPercent:TextInput5_Target.Text,
		DirectLaborHours:TextInput5_Direct.Text
	}
)

 

regards!

ehr
Helper I
Helper I

Brilliant! That worked perfectly. Thank you so much for all of your help and time!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

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