cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
grodinsm
Level: Powered On

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.

Super User
Super User

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!

grodinsm
Level: Powered On

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

Super User
Super User

Re: Create a second record entry from gallery

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

grodinsm
Level: Powered On

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. 

grodinsm
Level: Powered On

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
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 (6,004)