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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to populate a form...
Power Apps
Answered

How to populate a form's choice from a previous form submission

(0) ShareShare
ReportReport
Posted on by 19

Hello

 

I have 2 lists in Sharepoint: 

BasicInfo (ID, Name, CompanyName)

COVIDResponse (basicInfoID, Question1, Question2, Question(n+1) ..)

 

I have set COVIDResponse.basicInfoID to be a Lookup against BasicInfo, and set this as a required field.  On the sharepoint end of things, this works great - I must enter the data in BasicInfo first, then I am able to create a row in COVIDResponse - first selecting the correct basicInfo record before being able to create the COVIDResponse record.

 

I am trying to make a Powerapp for my users to use.  I've created the BasicInfo form without issue - data submits, etc.

 

On the next screen, I want to present the COVIDResponse fields.  Since I've made COVIDResponse.basicInfoID required, I need to know how to set it from the BasicInfo submission.

 

I have tried following https://wonderlaura.com/2017/08/16/powerapps-set-sharepoint-lookup-field/, but she's pre-populating (and pre-selecting) a field in a select list.  This method didn't seem to work in my application.

 

I have tried using the Lookup() function (following loosely on https://powerusers.microsoft.com/t5/Building-Power-Apps/Auto-populate-fields-based-on-the-users-inputs/td-p/104648) by settings the Items value to "LookUp('Basic Visitor Information', ID=BasicVisitor_Form.LastSubmit.ID)", but this resulted in an error - Items is looking for a Table value, and lookup returns a single record.

 

Help? 🙂

 

Thanks,

 

Tim

Categories:
I have the same question (0)
  • eka24 Profile Picture
    20,923 on at

    Do you want to have the previous submitted on your form.

     

    On the Onsuccess of the form put;

    Set(varLastsubmit,FormName.LastSubmit)

     

    Then on the forms ITEM put:

    varLastsubmit

     

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

    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.

  • Tim10 Profile Picture
    19 on at

    That generates an error "Expected a value compatible with DataSource".

     

    I think I know how to access previous form data.  I don't know how to populate a Lookup field with data from a submission to another form.

     

    If this were SQL, I would be thinking about how to set the "basicInfoID" to be the submission ID - but I'm not sure sharepoint works that way.

  • eka24 Profile Picture
    20,923 on at

    Maybe what you want to achieve is not clear enough. Do you want to populate a field based on the last Submit ID

     

    Can you give example

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

    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.

  • Tim10 Profile Picture
    19 on at
     

    Could be..  I'll post some screens from the actual app..

     

    This is "Basic Information" form - collecting a visitors name, company and their contact person.  This form is tied to a Sharepoint list.

    firstform.png

     

    This is the "COVIDResponse" form.  This collects personal information and some screening questions we're asking for visitors.  This is also tied to a Sharepoint list.

    secondform.png

     

    I would like to pre-populate "BasicVisitorID" with a reference of some sort to the first form's submission, so the user doesn't have to select it.  If I can get this to work, I would then hide the BasicVisitorID card.

     

    Does this help illustrate what I'm trying to do?

     

    Thanks for your help,

     

    Tim

     

     
  • eka24 Profile Picture
    20,923 on at

    My observation

    1. Your first form doesn't indicate any ID to populate the visitor ID in the second form

    2. To populate the dropdown with visitor ID, will depend on the ITEMS of the dropdown. What formula is in the dropdown.

    3. An alternative is to just insert a Textbox and put; BasicVisitor_Form.LastSubmit.ID

    Instead of dropdown if that would be ok.

     

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

    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.

  • Tim10 Profile Picture
    19 on at

    Hi

     

    I was hoping to use the Sharepoint ID that is generated when a record is added to the sharepoint list.

     

    The dropdown is defined as Choices([@'Private Visitor Information'].BasicVisitorID), and gives a list of numbers (that correspond to the rows in BasicInfo)

     

    Since BasicVisitorID is associated with a field in another Sharepoint list, can I just replace it with a text field with the ID?  Or does that break the .. "relationship" between the data rows?

     

    Thanks again for your help.

     

  • eka24 Profile Picture
    20,923 on at

    Based on the Items property of the dropdown you have shown, try these options:

    1. On Default of the dropdown

         varLastsubmit.ID

    That's Onsuccess of the form create a variable; Set(varLastsubmit, FormName.LastSubmit)

     

    Or

    2. Just insert a Textbox instead of the dropdown and put: varLastsubmit

    The relationship will not affect the variable

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

    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.

     

  • Tim10 Profile Picture
    19 on at

    Hi, thanks again for your ongoing help!

     

    1. Setting the default, I get an error in the editor:  Expected Record Value. The property on this control expects Record values. The rule produces Number values which are incompatible.

     

    2. I removed the dropdown from the field list, added a textbox, and set "varLastSubmit" as the Default value.  I got an error "Expected Text value. The property on this control expect Text values. The rle prdocues Record values which are incompatible.".

     

    I tried to set the default value to be varLastSubmit.ID (which actually generated an output in the textbox), but received this error when submitting the form: BasicVisitorID: Field "BasicVisitorID" is required.

     

    I set the data field of the card to "BasicVisitorID", but received the same output.

     

    Thank you again for your ongoing help. 

     

     

  • eka24 Profile Picture
    20,923 on at

    On the second point 2. 

    "this error when submitting the form: BasicVisitorID: Field "BasicVisitorID" is required"

     

    Am some how not clear. We are talking about 2 forms. On with the last Submit formula and the other picking the variable Last submit from the first form.

     

    Which form complains of the required field. 

     

    Also I suggest you remove the datacard as you suggested and insert a new one which contains the Datacarvalue. Then put the variable varLastSubmit.ID . Please not just a 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.

  • Tim10 Profile Picture
    19 on at

    Correct - 2 forms, on 2 different screens of the app.  1st form sets varLastSubmit onSuccess, and 2nd form is the one generating the error when I submit the form.

     

    I added a custom datacard to the form, and set its datafield to "BasicVisitorID".

     

    I added a TextField to that card, and set its default value to "varLastsubmit.ID". 

     

    When I move from the 1st screen to the second screen, I see the generated ID in the textfield.  Upon submission of the 2nd screen of the app is where I am seeing the "BasicVisitorID: Field "BasicVisitorID" is required." error message.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard