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

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

Hi @sasishaan

Glad my solution worked out for you.

And good note on the Selected property.

One thing you should take care of though is the Update Property, If you have your dropdown sitting in a DataCard

If so, then you should make sure the Update Property of the DataCard is set to:

Dropdown.Selected

 

As to your question about the BrowseGallery.Selected, this refers to the item in the datasource that is selected not the control in Powerapps, which means BrowseGallery.Selected.Project_Number will return the project number of the selected item on the browsegallery

 

Another small note, as I understood now you have a dedicated screen for items to be copied. If this is the case then you don't need the IsCopiedItem parameter since everytime you are navigating to this screen will be with a copied item so this won't ever be false. And also you don't need to write 

If(IsCopiedItem,CopiedProject_Number,Parent.Default)

you can simply write: CopiedProject_Number 

 

Best

Alaa

Highlighted
Frequent Visitor

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

@Alaa-Alarori

 

Thank you so much for your suggestions. Yes, i did make those changes as there are specific screens and forms for every need. I've tested all the possible scenarios and this functionality is working flawlessly. Our app is soon be available to the users. There some design changes i'm working through and it's good to go post that.

 

Just a generic doubt though. Any idea, what happens if multiple users are trying to copy the same entry at the same time? Will the session be locked to the user and will they be able to copy and duplicate the same item even if other users are doing the same? I'm not anticipating this frequently, but trying to make the app future proof. This won't be an issue with editing the entries as i've restricted the permissions in the background, only the users who made the entries can edit them. On the other hand copy functionality is universal and anyone with create items will have the permission to copy it by default.

 

Much appreciated if you could share your views on this. Besides that, i'm really very grateful to you for all the help .

 

Thanks,

Sasi.

 

 

Highlighted
Helper II
Helper II

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

@sasishaan

I don't expect any problems with many people copying those records at the same time, since each one of them is copying the record locally not directly from the sharepoint list, I even can't see a reason to prevent a sharepoint list handling few requests.

The only consideration would be if you are generating a unique sequential number for each record, in this situation you should make sure that those numbers are generated at the submit time not at the copy time

 

Best,

Alaa

Highlighted
Anonymous
Not applicable

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

Hi,

 

In my scenario, I'm using a customized PowerApp form on a sharepoint list.

On the sharepoint list when we click on an item to view that was already created, this item will open on customized PowerApp Form where wecan only 3 options as in below image.

Is there any way we can copy an item from previous item  and edit it  and create as new when we save on shrepoint list.

Please let me know if you have tried this.

 

Thanks in Advance.

 

Highlighted
Advocate I
Advocate I

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

Here's something I've done that works for me with a small difference in the workflow, I wanted also to have a 'save as' button on the form that would save the current form values in a new item, and edit it right away. So different from your flow where you have "(not yet stored on the data source)".

My flow is 

1- Click on an item to view the form (view mode)

2- Or/And Edit the item (edit mode)

3- When the form is in edit mode I have a button that is visible named 'save as'

4- At that time, I can change anything on the edited item

5- I can click on save to modify edited item, click on cancel to cancel all changed and revert to what was last saved or click on the 'save as'

6- Clicking on the 'save as' will take the current form values (Collect) and add a new item in the list

7- Then right away edit that last added item (so if you were to display the ID you'll see the new ID)

 

at that point it goes back to point 4.

 

To do that, I have a button that appears only when the form is in Edit mode, in its select I have a Collect, I set a global variable gSaveAs to true and execute the EditForm/Navigate that will open a new form

The purpose of the global variable is to load the 'last item' when the form is presented, so in the 'item' of my form I have

 "If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected), First(lReadiness), If(gSaveAs, Last(llReadiness), SharePointIntegration.Selected))"

 

here I'm taking a risk that the last item may not be mine if multiple people are doing it at the same time, maybe there's a way from the 'Collect' function to get the ID of the new record, I've been using powerapp for a couple of days so I haven't explored everything yet.

 

so with that the last thing I need to do is to reset the flag so that future edit don't always show the last item, I reset the global variable in the 'on success' of the form and onView of the sharepoint integration object., I don't really care to let the variable set if the user continue to click on 'save as' but I do care if the user closes the current form and get back to it at a later time.

 

I know possible side effects if the user doesn't save (ie doesn't go in onSuccess) or select the item and go in edit without passing through the view mode, I'm thinking I could reset the variable also in the other 'on save','on cancel' of the integration object but haven't tested that much to be sure. i've tried to find a place where I could safely reset the variable and couldn't find something that was straight forwards.

 

For example I tried to do set the variable, then do the EditForm/Navigate, then reset...for some reason the edit/navigate is happening after I reset the variable, while I need my 'item' code to run before I could reset the variable, I also tried to reset the variable in the 'item' IF statement but couldn't... what would really be full proof is if I could do the following :

 

 "If(IsBlank(SharePointIntegration.Selected) || IsEmpty(SharePointIntegration.Selected), First(lReadiness), If(gSaveAs, Set(gSaveAs, false) ; Last(llReadiness), SharePointIntegration.Selected))"

 

but it doesn't let me do that... any clue? 

 

anyway the rest works perfectly. may not be perfect but I spent the last 2 days trying to figure that flow

Helper I
Helper I

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

@sasishaan @Alaa-Alarori  Kind of confused on what you're saying the correction is. Hopefully you can help and clarify.

 

In my example, I have a field called DETAILS (the data card is DataCardValue1

and a drop down field Project_Name (data card is DataCardValue2) which is a reference field in the same list 

 

So are you saying if I am in the DetailsScreen and I make a button called copy record, the correct method that worked for you for the OnSelect is:

NewForm(EditScreen1);Navigate(EditScreen1,ScreenTransition.None,{IsCopiedItem:true, DataCardValue1.Selected, DataCardValue2.Selected})
Highlighted
Frequent Visitor

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

Hello,

Is this the only available option or is it already possible to edit an existing item and have a duplicate button that will create a new item and copy the data from the existing item and set the PowerApp to FormMode.New?

Thanks

Highlighted
New Member

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

Really useful - thanks 🙂

Helpful resources

Announcements
Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,615)