cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dmistry
Post Prodigy
Post Prodigy

Populating a text field from previous sharepoint submission

Hi,

 

I have a powerapp linked to a sharepoint list as source and on the form, for a text field, I would like to prepopulate it with the value coming previous sharepoint form submission.

 

SO basically this form is submitted every month so one row entry in sharepoint gets logged. So I just want to populate this text field with value coming from previous submission in sharepoint, can someone please help, thanks in advance. Also I want to make sure this to work for form in new item mode not for edit mode. thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @dmistry ,

Do you want to pre-populate a Text field within your Edit form based on previous submission?

Further, do you want to pre-populate the Text field when the Edit form is in New mode?

 

Based on the needs that you mentioned, I think the Last function could achieve your needs. Please consider set the Default property of the Text Input box within specific data card in your Edit form to following:

If(
   EditForm1.Mode = FormMode.New,
   Last('Your SP List').TextFieldName,
   Parent.Default
)

Note: The 'TextFieldName' represents the Text type field name within your SP List

 

In addition, I think variable could not achieve your needs. The variable could only work in current session, if you close your app, the variable value would be cleared.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
eka24
Super User
Super User

To do this on a NewForm, Follow these steps:

1. Insert a Gallery1 with the items linked to the datasource

2. On your form item property, put Gallery1.Selected

3. Whatever selected in Gallery1 will populate the form in EditMode

 

4. Instead of Using SubmitForm, Use Patch Function to avoid editing the Old records:

  Patch('[dbo].[DataSource]',Defaults('[dbo].[ DataSource]'),
{FirstName: TextBox1.Text,
ReceipientName: TextBox2.Text,
FullName: TextBox3.Text,
EntryDate: DatePicker1.SelectedDate})

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

    

thanks @eka24 for answer, I dont think it answers my question, I am looking to pre populate text field with value coming from previous sharepoint submission for same field , this way users dont have to enter it by themselves on the form.

The steps I gave does exactly that Using Patch if the submission was done some time ago. You said it will be done monthly. If it is just a textbox, you use: Gallery1.Selected.ColumnName.

 

However, If the Submission of the previous form was just in a moment and not on monthly basis, then make use of LastSubmit function.

Let say Form1 is the Original form you submitted. Insert another Form2 and set its Items to

  Form1.LastSubmit  --- This populates all record which was last successfully submitted to the sharepoint

 

If just a textbox use: Form.LastSubmit.ColumnName

 

Watch this video form additional information on last Submit:

https://youtu.be/N8DWvS7P9lw?t=874

 

Finally, you can use:
 ClearCollect(CollMydata,YourDataSource) OnStart of the App or Onvisible of the Screen.

Then in the TextBox Put:

    Last(CollMydata).ColumnName In the TextBox

 

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

v-xida-msft
Community Support
Community Support

Hi @dmistry ,

Do you want to pre-populate a Text field within your Edit form based on previous submission?

Further, do you want to pre-populate the Text field when the Edit form is in New mode?

 

Based on the needs that you mentioned, I think the Last function could achieve your needs. Please consider set the Default property of the Text Input box within specific data card in your Edit form to following:

If(
   EditForm1.Mode = FormMode.New,
   Last('Your SP List').TextFieldName,
   Parent.Default
)

Note: The 'TextFieldName' represents the Text type field name within your SP List

 

In addition, I think variable could not achieve your needs. The variable could only work in current session, if you close your app, the variable value would be cleared.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

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 (2,528)