cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Chrom3d
Level: Powered On

AutoFill a Form from previous records?

Hi 

 

So my project is done and dusted - I have created a visitor registration app from powerapps, everything is working smoothly then I was hit by a question which i haven't thought about in the first place. 

 

"Is there a way so that frequent visitors won't have to fill in the form everytime they come in?"  - facepalm

 

backstory is I have a sharepoint list with visitor records to whom the "Form" is connected to, the Form updates the sharepoint list whenever someone logs in with their name, company, phone number and person they want to visit. They log out, the column gets updated with the current date and time. Gallery does not show the records whose log out column is already filled in.

 

The big question is, is it possible to autofill a form with previous records of people who have visited? like a history? How will this be pulled off with Powerapps? I think you can only connect one data to a Form. This is the last hurdle from my project and any help will be greatly appreciated.

 

Kind regards

 

Chrom3d

 

 

7 REPLIES 7
Meneghino
Level 10

Re: AutoFill a Form from previous records?

Hi @Chrom3d

Yes, this can be done.

Obviously the details depend a bit on what exactly it is you want to do, but for example you can use the StartsWith() function to query the history list using the person's name and get the data of the last record in the history list.

However, this may require customisation of any forms that you have in your app.  I generally prefer not to use forms at all but create my own form the individual controls.  Once you start customising the out-of-the-box froms, it is often easier to start from scratch.

Community Support Team
Community Support Team

Re: AutoFill a Form from previous records?

Hi @Chrom3d,

 

Meneghino offers a workable way to deal with the situation, to filter the table first, and then get the last record. 

Formula should be:

Last(filter(SPList, UserName=User().FullName))

To work with Form control, and to have the value auto-filled by the previous record submitted by the same person, we need first find the record, and then specify the value to the Default property of the corresponding DataCard control.

For example, under the Company DataCard of the Editform control, and we would like the value to be auto-filled with the Company name last submitted by the same user, we configure the Default property of the Company DataCard control with the formula below:

 

 

If(
   !IsBlank(filter(SPList, UserName=User().FullName)),
   Last(filter(SPList, UserName=User().FullName)).Company,
    "")

Formula here means if the user has records submitted, it will then display the company last submitted, if not, it will display nothing.

Configure the same way for the other DataCard.

Let me know if it works.

Regards,

Michael

Community Support Team _ Michael Shao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Chrom3d
Level: Powered On

Re: AutoFill a Form from previous records?

Thanks for the suggestion, this makes sense to me now alotugh not 100% yet. I've never tried this before and will try to crack it when I get the chance. Will let you guys know how it goes!

 

just question on the formula, I have to apologize again for being a code newbie

 

Last(filter(SPList, UserName=User().FullName))

 

"SPList" = Sharepoint list which is obvious 

 

 

"UserName =is the column?

"User().FullName"  = says in the manual "Full name of the current user, including first and last names." I I am not pulling any users from let's say Office365, it's just random people from diff institutions and they might just put in Jake or Bob instead of their full names. Would there be an alternative instead of using "User().FullName" or is it the correct syntax which pulls in data in Sharepoint that is labeled as name?

Chrom3d
Level: Powered On

Re: AutoFill a Form from previous records?

I forgot to ask too where should I put this formula? 

 

Last(filter(SPList, UserName=User().FullName))

 

on the VisitorName DataCard's default data? Same as the location of

 

If(
   !IsBlank(filter(SPList, UserName=User().FullName)),
   Last(filter(SPList, UserName=User().FullName)).Company,
    "")

 

In the company's data card 

Air
Level: Power Up

Re: AutoFill a Form from previous records?

Did you manage to work this all out?

Super User
Super User

Re: AutoFill a Form from previous records?

Hey @Chrom3d,

 

 

The Last function is already used in the If statement so you dont need to put it elsewhere.

UserName is a context variable that is initialized on the OnStart or OnVisible of the first screen you show to your endusers.

So something like this: UpdateContext({UserName: User().FullName})

 

Kind regards

 

 

Tom





Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!





SufyanM
Level: Powered On

Re: AutoFill a Form from previous records?

Hi @Chrom3d 

I am doing a similar project to yours. I am new to PowerApps and coding. I am currently stuck on autofill date and time of visitors. is there a way you can share your app model with me, so that i can see your method of solving this model ??

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 347 members 5,911 guests
Please welcome our newest community members: