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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Retain some form data ...
Power Apps
Answered

Retain some form data after submitting.

(0) ShareShare
ReportReport
Posted on by 225

I have a form to record visitor details and after submitting the form I want most fields to clear, but the "Host" and "Visiting Site" fields to retain their values as this info will always be the same for the session and dont want to have to keep retyping the "Host" and "Visiting Site" details.

 

The only time the "Host" and "Visiting Site" fields should be cleared is when the "Restart" button is selected.  How can i clear most fields, but keep "Host" & "Visiting Site" populated when the form is submitted?

 

 Thanks in advance, 

pa frm.png
Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,991 Moderator on at

    @StuartSmith 

    When the form is submitted successfully all its data gets stored in the LASTSUBMIT property of the form.  We can make some changes to the Default properties of the Cards for Host and Visiting Site to capture this information.

    Put this code in the Default property of the Card for Host.

     

    If(
     IsBlank(Form1.LastSubmit.'Host'),
     Blank(),
     Form1.LastSubmit.'Host'
    )

     

    Also put this code in the Default property of the Card for Visiting Site.

     

    If(
     IsBlank(Form1.LastSubmit.'Visiting Site'),
     Blank(),
     Form1.LastSubmit.'Visiting Site'
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • yashag2255 Profile Picture
    24,769 Super User 2024 Season 1 on at

    Hey @StuartSmith 

     

    If you want to pass the same value for all the records, you can set the configuration as:
    a) Please add the appropriate datacards and the Visible property as false.
    b) In the Update property of these datacards, pass the value that you want to be constant. This could also be a variable that can be set based on the control or Value.
    Note: The update property should be passed in the correct format.

    If this doesn't help, please share more details about the scenario.

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

  • StuartSmith Profile Picture
    225 on at

    I tried your solution on the "Host" field and the form field remain empty after clicking the submit button (see attached).  Could it be because the "Host" field is a "Name Lookup" value?

     

    The code I used on the "Card" default value was "If(IsBlank(Visitor_Registration_Form.LastSubmit.'Host'),Blank(),Visitor_Registration_Form.LastSubmit.'Host')"

    empty field.png
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @StuartSmith 

    I will suggest a different approach now based on some tests I ran:

     

    Put this code in the OnVisible property of your screen

    Set(currentID,Blank());
    Set(currentVisitingSite,Blank());

     

    Put this code in OnSelect property of your Submit Form button

    SubmitForm(Visitor_Registration_Form);
    Set(currentHost,Visitor_Registration_Form.LastSubmit.Host);
    Set(currentVisitingSite,Visitor_Registration_Form.LastSubmit.'Visiting Site');
    NewForm(Visitor_Registration_Form);

     

    Use this code in the Default property of the Card for Host

    currentHost

     

    Use this code in the Default property of the Card for Visiting Site

    currentVisitingSite

     

    Note: the prior solution not working was due to the LastSubmit data clearing when we put the form back into New mode.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • StuartSmith Profile Picture
    225 on at

    Thanks for taking the time to supply an alternative solution.  I done as you suggested and the code was accepted (no red crosses), but upon pressing the "Submit" button, the details are not submitting it to the sharepoint list and the gallery on the form, they just stay showing on the form.

     

    Any ideas?

  • StuartSmith Profile Picture
    225 on at

    Another option, would be to disable the "Host" and "VisitingSite" combo boxes if 1 record has already been submitted and then pre-populate the "Host" and "VisitingSite" values of any additional rows with the "Host" & "VisitingSite" values found in the first row?  Don't know if that would be easier?  Hope that makes sense.

  • StuartSmith Profile Picture
    225 on at

    So ultimately, what I want to achieve is that no matter how many rows are added for the current session, the "Host" and "VisitingSite" details will always be the same as row 1.

  • mdevaney Profile Picture
    29,991 Moderator on at

    @StuartSmith 

    "Thanks for taking the time to supply an alternative solution.  I done as you suggested and the code was accepted (no red crosses), but upon pressing the "Submit" button, the details are not submitting it to the sharepoint list and the gallery on the form, they just stay showing on the form.  Any ideas?"

     

    I want to know why the form is not submitting.  Please create a label with this code in it.  Does any error appear in this label after you click submit?

    Form1.Error

     

  • StuartSmith Profile Picture
    225 on at

    Hi, I managed to get the "Host" one working, i simply removed/re-entered your code. But oddly the"Visiting Site" combo box doesnt display the current value?    see attached.

     

    The code I am using is...

    Set(CurrentVisitingSite,Visitor_Registration_Form.LastSubmit.Visiting_x0020_Site);  or

    Set(CurrentVisitingSite,Visitor_Registration_Form.LastSubmit.VisitingSite); (this is how the sharepoint list column is named)

     

    I also removed the line 

    NewForm(Visitor_Registration_Form);

    as this was preventing the form data from showing in the gallery. 

     

    I have also been trying to set the "DisplayMode" of the host field to "view", using the code

     

    "If(IsBlank(CurrentHost), DataCardValue14_1.DisplayMode.View, DataCardValue14_1.DisplayMode.Edit);"

     

    But also cant get that to work. 

    Thanks in advance, 

    Host Yes Visiting site no.png
  • StuartSmith Profile Picture
    225 on at

    I have also been trying to follow your example and display the CurrentVisitngSite value in a lablel, but current trying to figure out the code.

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
Haque Profile Picture

Haque 70

#2
WarrenBelz Profile Picture

WarrenBelz 64 Most Valuable Professional

#3
Kalathiya Profile Picture

Kalathiya 36 Super User 2026 Season 1

Last 30 days Overall leaderboard