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

How to create a copy of an existing item and show it in an Editform

I have a form which when the user submits it , the data is stored in SQL.

 

I need to implement a "copy item" on the custom made form which I created with 3 screens ( New Form, Edit Form, View Gallery- which basically shows all the forms that user has submitted )

 

I am now looking to add this "copy an exisitng form" feature to  my App. 

 

1) User has selected a random form in the gallery 

2) User hits a "Copy Item" button.

3) App creates a new form. (not yet stored on the data source).

4) App copies over the values from the selected, old item to the newly created one.

5) App shows the EditForm to edit the newly created item (form would be in FormMode.New). 

 

My second question is:  when the user creats a new item and submits it, its data is stored in sql table, however when the user modifies and resubmits the form It just updates the last updated data. I want to have a way to store the history of all the newly and modified data in the table. How can I do that?

 

 

 

Any ideas on how to get this done would be highly appreciated.

Thank you

Daniel

1 ACCEPTED SOLUTION

Accepted Solutions
TimRohr
Level 10

Re: How to create a copy of an existing item and show it in an Editform

So let's say your form is called MyForm on a screen called MyFormScreen... in your button for "Duplicate Form" (or whatever you call it), you would do something like:

 

NewForm(MyForm);Navigate(MyFormScreen, ScreenTransition.None,
{defField1: Field1.Text,
defField2: Field2.Text,
defField3: Dropdown3.Selected
})

The third argument in the Navigate() statement passes Context Variables to the destination screen. Once you have those, you can use them in the default property of the fields on your MyForm... Field1 for example:

If(!IsBlank(defField1),defField1,"")

Passing a context variable with the Navigate() function isn't the only way to create them... you can use the UpdateContext({}) function to create or change them, too.

4 REPLIES 4
TimRohr
Level 10

Re: How to create a copy of an existing item and show it in an Editform

"Creating a duplicate Form" is your process, but you really want it to create a new record in your source, right?

 

Pass the field contents of the existing form as variables into the New-item form, thinking of them as defaults. Then, in each control, use the Default property to read if the associated variable IsBlank, and populate accordingly. When the user commits the record, it will be stored as a new record on your datasource. The data will be created from the original "copied" form, but they will have the opportunity to change it before saving their work, which will be a "new" form.

asdeev
Level: Powered On

Re: How to create a copy of an existing item and show it in an Editform

Can you please give me with an example on this? I understand the concept but I am not so good at variables.

 

Could you please elaborate on this a bit more?

 

And yes, the copied form should be saved as a new entry in the db.

 

Thanks a ton!!

 

TimRohr
Level 10

Re: How to create a copy of an existing item and show it in an Editform

So let's say your form is called MyForm on a screen called MyFormScreen... in your button for "Duplicate Form" (or whatever you call it), you would do something like:

 

NewForm(MyForm);Navigate(MyFormScreen, ScreenTransition.None,
{defField1: Field1.Text,
defField2: Field2.Text,
defField3: Dropdown3.Selected
})

The third argument in the Navigate() statement passes Context Variables to the destination screen. Once you have those, you can use them in the default property of the fields on your MyForm... Field1 for example:

If(!IsBlank(defField1),defField1,"")

Passing a context variable with the Navigate() function isn't the only way to create them... you can use the UpdateContext({}) function to create or change them, too.

Highlighted
asdeev
Level: Powered On

Re: How to create a copy of an existing item and show it in an Editform

Thanks a lot Tim!!!

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 187 members 5,301 guests
Recent signins:
Please welcome our newest community members: