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.

View solution in original post

4 REPLIES 4
Highlighted
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.

View solution in original post

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
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
Users Online
Currently online: 203 members 5,487 guests
Please welcome our newest community members: