cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Re: Create a second record entry from gallery

Ohh, I missed that part, sorry. Yes, putting displayitem as the items field worked, however now it's showing rnew as it was in the state before the second patch where I dropped columns. Almost there! Thank you for all of your help so far.

Highlighted
Power Participant
Power Participant

Re: Create a second record entry from gallery

I'm happy to help!

 

Ah yes, of course! You set that variable when you did the first Patch so it keeps those values.

 

It should work by setting it again in the Patch where you use the collection to set all the column values, so:

 

Set(rNew, Patch('[dbo].[Intake_form]',{Form_Number:IDVar},First(updcoll))); Patch('[dbo].[Intake_form]',ThisItem,{Current:"N"});
EditForm(Form1);
Navigate(Screen1, ScreenTransition.None,{displayitem:Filter(Collection1,Form_Number=IDVar)})

 

I out the changes in bold italics. 

 

Good luck!

Highlighted
Helper I
Helper I

Re: Create a second record entry from gallery

That did the trick!! I was about to reply and say it had reverted back to displaying the original entry again, but realized I had put the closing bracket for the SET in the wrong place. 

 

Here is the final code for anyone who is in a similar situation:

 

UpdateContext({ResetVar: true}); 
UpdateContext({ResetVar: false});
 Set(rnew,Patch('[dbo].[Intake_form]',Defaults('[dbo].[Intake_form]'),
{First_Name:ThisItem.First_Name}));
Set(IDVar,rnew.Form_Number);
ClearCollect(updcoll, DropColumns(Collect (upd2,ThisItem),"Form_Number"));
Set(rnew,Patch('[dbo].[Intake_form]',{Form_Number:IDVar},First(updcoll))); Patch('[dbo].[Intake_form]',ThisItem,{Current:"N"});
EditForm(Form1); 
Navigate(Screen1, ScreenTransition.None,{displayitem:rnew})

And then on the form1 screen, change the Items property to "displayitem"

 

Thank you very much @BitLord69, couldn't have done this without your help. 

View solution in original post

Highlighted
Power Participant
Power Participant

Re: Create a second record entry from gallery

You're welcome! And besides, it was a team effort! 🙂

Helper I
Helper I

Re: Create a second record entry from gallery

Hmm... A strange side effect has happened after all of this. Previously, when I clicked the Save button when looking at the edit screen, all of the changes to the fields would disappear, and then after a few seconds come back. now... they don't reappear. The data is saved, and clicking back, and then clicking edit again shows the correct data, but this will scare my users into thinking they've lost all of their work. 

 

the only thing that has changed from when a user "edits" a record (instead of duplicating) is the change from ITEMS being displayItem instead of gallery.selected.  @BitLord69 any idea what change has to go along with this to get the desired action? I essentially want the form to re-load the latest values in the database after SubmitForm(Form1) fires. 

 

OnSuccess is the default "Collect(Collection1, Form1.Current)", I tried "Collect(Collection1, displayItem)" but that didn't make a difference. 

Highlighted
Helper I
Helper I

Re: Create a second record entry from gallery

Update: I figured it out! the OnSuccess needed to be changed to re-set the content of displayItem:

 

Set(displayItem,Collect('[dbo].[Intake_form]',displayItem))

 

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,977)