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 / Submitting Active Form...
Power Apps
Answered

Submitting Active Forms with a Single Button

(0) ShareShare
ReportReport
Posted on by 163

Hey all,

 

I have a screen in my app like this:

stephenkln_0-1594233430344.png

It contains multiple forms to submit data to different but related sql tables. I have it set up so that if you click the add icon, the form will open to populate data (employeeid prepopulates based on the selection from a previous screen). Selecting the trash icon will close the form and erase any values that were added. Each form is independent of the others.
I want to wire them all up to a single submit button. That I can do. The part I'm stuck at, is I want the button to submit only the open forms that have data filled in. 

I attempted this with a nested If(Form1.SelectedDate<>Blank()),SubmitForm(Form1) and so on...But this is not really doing what I need. Any ideas? Thanks!

Categories:
  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @stephenkln 

    Have you looked at the Unsaved property of your form?  Perhaps you can utilize that to determine if it needs to be saved.

    Also you can consider looking at the mode of the Form to determine what it is doing.  If you are using NewForm to "new" a form, then the mode would be FormMode.New.

    So something like this:

    If(Form1.FormMode=FormMode.New && Form1.Unsaved), SubmitForm(Form1));
    If(Form2.FormMode=FormMode.New && Form2.Unsaved), SubmitForm(FOrm2));

     

    I hope this is helpful for you.

  • KrishnaV Profile Picture
    5,023 on at

    Hi @stephenkln ,

     

    Unfortunately, this is a wrong approach, You should implement this with the collection, Try this:

    1. Add a date for Employee Date and text field for employee ID on the screen
    2. onSelect of the "+" icon add a row to collection as below

     

    Collect(collEmpDetails,{EmpDate:datepicker.SelectedDate,EmpID:empIDtext.Text})​

     

    • Now you add a gallery to screen and assign the collection to the gallery
    • in the gallery you add the trash Icon and set the formula of OnSelect as below:

     

    Remove(collEmpDetials,thisitem)​

     

    • Now on your submit button write a Patch as below

     

    ForAll(collEmpDetails,
    Patch(SPList,Defaults(SPList),{clm1:EmpID,empDatecolumn:empDate}))​

     


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @KrishnaV 

    I believe the key statement in @stephenkln post is that he has these forms all going to separate SQL tables.

    Agreed that a different approach would be perhaps a better one, but if they are all going to different SQL tables, the suggested approach would not work and additional logic would be necessary. 

    We could suggest some, but I will wait on a response from @stephenkln to see if he wants to take that avenue.

  • stephenkln Profile Picture
    163 on at

    @RandyHayes @KrishnaV Thanks for the responses guys. @RandyHayes Yes, to confirm, these forms are individual forms that are each going to separate related SQL tables. 

     

    Using If statements on the submit button does not work because as soon as one form submits successfully, it terminates the rest of the statement. I could not think of a way to write it to get around this.

     

  • KrishnaV Profile Picture
    5,023 on at

    hi @RandyHayes ,

     

    I totally agree with you but the solution I proposed as per his screenshot, I believe my understanding is that all the data in the screenshot should go on to a single table.

     

    If I am wrong I am also ready to say SORRY for my wrong interpretation 😊


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @KrishnaV 

    😊 No worries.  I only mention because I thought the same thing at first when I saw your response, but as I re-read, I noticed that they were all going to different tables.

     

    @stephenkln 

    So here would be my next question...do you really need a Form control?  You appear to have two fields in your form.  If you can strip out the Form control and do a hybrid approach of what @KrishnaV suggested with building a collection of entry values and then, when submitting, instead of a SubmitForm, you could go through the collection and, based on what table it represents, you could put your logic in that formula to Patch/UpdateIf the appropriate SQL table with the provided values.

     

    There is some non-described statements above that you may or may not need further explanation on.  But rather than dig into the details of something that might not work in your scenario, I put it out as a potential solution to consider.  If that would work for you and you need further detail on any of the above...we're all here!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @stephenkln 

    The formula should continue to execute other statements even after the submit.  You might have some issue with your If statements.  The formula I mentioned should work successfully even for multiple forms.  SubmitForm does not "stop" the execution of additional statements.

  • stephenkln Profile Picture
    163 on at

    @RandyHayes Honestly, I don't know if I need a form control lol. This is my first app so I'm learning as I go. From my standpoint it seemed the simplest--albeit maybe not the most efficient way to get the functionality I need.

     

    I think I understand the concept behind @KrishnaV 's approach, but I don't know how to implement it.

     

    For clarity, let me explain what I need to do and maybe that will help with solutions.

     

    The app is wired up to a SQL db storing employee data. All the tables are normalized. The purpose of the app is to view historical records by employee as well as add new records.

     

    A user opens the app and selects an an employee from a list on the previous screen which also displays their most recent records.

    They need to add some new records so they click a button that takes them to the screen we are discussing.

     

    I'm trying to build some way for the user to independently add records for the selected employee. (There are approximately a dozen individual tables related to the employee table.)

     

    The user needs to be able to add records to all the tables, or some of the tables via this screen and submit them all with one click in a batch.

     

    I guess the tricky thing about this whole thing is if it was one big form going to a de-normalized table it would be simple. But it's multiple normalized tables that need to be updatable via one screen. Setting up the individual forms in the way I did was my clunky attempt to replicate the functionality of a single form to update all or some of the tables.

     

     

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @stephenkln 

    So, just to get some clarity.  Although you might have lots of normalized tables, the particular screen you showed seemed to have all the same type of Forms.

    To be clear - you are saying that each and every one of those forms is "wired" to a different table?  Or, is it that, on that screen, each new entry form is going to the same table?

    i.e  Which scenario is yours?

    A) Form1 - to Table1, Form2 - to Table2, Form3 - to Table3, etc.

    B) Form1 - to Table1, Form2 - to Table1, Form3 - to Table1, etc.

  • stephenkln Profile Picture
    163 on at

    @RandyHayes The forms all look the same for uniformity, but they are all wired to different tables. 

    We are dealing with this scenario: A) Form1 - to Table1, Form2 - to Table2, Form3 - to Table3, etc.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 258

#3
Mohsin Ali Profile Picture

Mohsin Ali 231

Last 30 days Overall leaderboard