cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Meneghino
Level 10

Re: Save data from multiple screens to submit

How many  input fields do you have? For three input fields the expression is still very compact:

Patch(MyDataSource, Defaults(MyDataSource), {MyTextColumn: TextInput1.Text, MyNumberColumn: Value(TextInput2.Text), MyOtherColumn: TextInput2.Text})

There is no limit that I have yet met for characters in a PowerApps expression, my longest one to date is probably a about a thousand characters.

 

Can't comment on the roadmap as I am a simple user...

ColinI
Level: Powered On

Re: Save data from multiple screens to submit

Thanks.  Well the form I'm currently considering has at least 20 fields.  I've decided to use Forms, with the Updates syntax of Patch.  My data source are SharePoint Online lists.  There is a main "parent" list and several "child" lists.  It took me a while, but I firgured out a way to use the Patch function to import a default value of a "key" field in the parent form into its counterpart in a child form.  So solutions involving Patch (rather than SubmitForm, EditForm, etc.) are of particular interest to me in developing apps of this type.

egboud
Level: Power Up

Re: Save data from multiple screens to submit

Colinl, can you please share your Patch code. I am still having problems wit my Sharepoint list.

Thanks in advance.

 

Erwin

Highlighted
ColinI
Level: Powered On

Re: Save data from multiple screens to submit

Sure.  Not sure if the below will make complete sense to you (I've tried to be generic), but it assumes a "Creator Form" to initialize a new parent form record; the "Parent Form" itself for data entry; the "Child Form Screen" that has a "Child Form" to add rows to a "Child Gallery List" on the same screen; and a "Browse Gallery List" for the created parent records.  Sorry for any typos.  Still a work in progress ...

 

OnSelect code for Button to Open Parent Form Screen
===================================================
Refresh(<SPParentList>)
; ResetForm(<ParentFormName>)
; Patch(<SPParentList>, Defaults(<SPParentList>), <CreatorForm>.Updates)
; Navigate(<ParentFormScreenName>, Fade)
; NewForm(<CreatorForm>)

 

OnSelect code for Button to Open Child Form Screen
==================================================
NewForm(<ChildFormName>)
; Navigate(<ChildFormsScreenName>, Fade)

 

OnSelect code for Button to "Save and/or Submit" Parent Form
============================================================
If(<CreatorForm>.Mode = New
, Patch(<SPParentList>
, First(Filter(<SPParentList>, ID = Value(<ParentKeyDataCardValueNumber>.Text)))
, <ParentFormName>.Updates
)
; Navigate(<AfterSubmitScreenName>, Fade)
, Patch(<SPParentList>
, <BrowseListGalleryName>.Selected
, <ParentFormName>.Updates
)
; Navigate(<BrowseListScreenName>, Fade)
)

 

OnSelect code for Button to Save new line to Child Gallery
==========================================================
Patch(<SPChildList>, Defaults(<SPChildList>), <ChildFormName>.Updates)
; Refresh(<SPChildList>)

 

OnSelect code for Button to Return to Parent Form Screen
========================================================
Navigate(<ParentFormScreenName>, Fade)


OnSlect code for button to "Cancel" the newly created parent record
===================================================================
If(<CreatorForm>.Mode = New,
RemoveIf(<SPParentList>, <ParentKeyDataCardValueNumber>.Text = ID)
; RemoveIf(<SPParentList>, <ChildKeyDataCardValueNumber>.Text = <SPChildListKeyField>)
; Navigate(<AfterCancelScreenName>, Fade)

, Navigate(<BrowseListScreenName>, Fade)

)

egboud
Level: Power Up

Re: Save data from multiple screens to submit

Great!! This definitely makes sense.

Thanks

 

tianaranjo
Level 8

Re: Save data from multiple screens to submit

@murali  -- Hoping to revisit this solution.  I have a similar need, submit data from multiple screens on a New form.  I implemented the solution from this post, (shown below), and wanted to check if this is a reasonable solution.  This is working for me with a new entry -- where in the original message, you discussed using the Updates for an item being edited. 

 

My questions then is -- is this a viable solution for submitting a new form collected from multiple screens?  Or should I use Patch?

Patch('Datasource',Defaults('Datasource'),
frmAddNew.Updates,frmAddNew_2.Updates, frmAddNew_3.Updates, frmAddNew_4.Updates, frmAddNew_5.Updates)

realik
Level: Powered On

Re: Save data from multiple screens to submit

Hi

I have a similar setup - but I am approaching it slightly differently.  I have a table with about 50 fields that, depending on specific fields, are then split into screens for form entry.  Can you share how you would do the Patch function for 20+ fields in one table (for a new entry)?  So far I have 

Patch( MyTable, Defaults( MyTable), ...)

How would I implement an Update in the Patch function for the different screens that contain fields in the table?

CoolingPowerApp
Level: Powered On

Re: Save data from multiple screens to submit

Hey realik,

 

So I don't exactly understand your question but I think I can help. The way I see it you have a table with 50 columns. You desire to create a new entry for 20 or more of these columns (fields) at a time right? I think you have a few options. 

 

You could just use a collect function. It won't update already created rows, but it doesn't sound like you need that. I am writing this assuming that your users are using things like text input boxes and drop down menus to enter their information. I think it would look like

Collect(MyTable,{TextInput1: TxtInpt1.text, DropDown1: DrpDwn1.Selected.Value, TextInput2: TxtInpt2.Text, .... })

Where TxtInpt1 is the name of the text input box that the user would enter the information you desire in the TextInput1 column. Collect can collect information across screens.

 

Your second option is very similar, just use the patch function. I believe you have it written correctly already, just need to fill in the column links.

 

The last option I can think of involves edit forms. One thing I have done is set up a screen, S1, and on S1 there are just text input boxes and drop down menus. Then I set up a asecond screen, S2, which contains and Edit Form. I put every single column into this Edit Form, so essentially it is a really long edit form with every field in it. Then I change the update field of each data card to the name of the corresponding text box from S1.

 

It would go like this. You have the text box TxtInpt1 on S1. You have the TextInput1 data card on S2. Set the TextInput1 data card's update value to TxtInpt1.text. Now when you SubmitForm(EditForm1) you will find the information from TxtInpt1 in the TextInput1 column in your database.

 

You could have one screen for each column (field) if you wanted to, it doesn't matter as long as you set all of the data card's update fields correctly.

 

I have used each of these methods succesfully in my own apps, so I believe they could work for you as well. I hope this helped.

realik
Level: Powered On

Re: Save data from multiple screens to submit

Thank you for the response! 

 

I have created the command for submitting 3 forms for a new entry intio a single sharepoint record (multiple fields on each form) as follows:

 

OnSelect = SubmitForm([@NewForm1]);Patch(TracsBatchJobs,NewForm1.LastSubmit,NewForm2.Updates,NewForm3.Updates);SubmitForm([@NewForm3]);Navigate(BrowseScreen1, Fade)

 

It was almost working - but seems to have broken when I copied the submit...I say almost because it would submit but it would submit 2 records...one for form 1 & 2 and then one for form 3 (so I would have 2 entries...

 

Suggestions? 

CoolingPowerApp
Level: Powered On

Re: Save data from multiple screens to submit

Hey realik,

 

I've been experimenting with submitting two seperate forms as one sharepoint list entry and I have not had much success using actual forms. The method using Collect(), Patch(), and regular text boxes I described earlier worked fine. 

 

From first glance I can tell that your equation contains two different SubmitForm() statements, so essentially you are submitting two different records. I believe this is why two records would be created. Remove that second SubmitForm() and see what happens.

 

I hope this helps.

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 (Last 30 Days)
Users online (4,962)