cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SenoirB
Advocate I
Advocate I

Copy a record

Hello,

I'm stumped. I have two apps that use the same data source. I am following these steps to create a duplicate of a record on both apps:

 

Gallery item OnSelect=

Set(varCurrentRecord, ThisItem); Navigate(EditForm1Screen)

Copy button on EditForm1 Screen =

UpdateContext({locCopy:true})

EditForm1 Item =

If(locCopy=true, 
Patch(varCurrentRecord,{ID:Blank()},{Title: Blank()},{Status: Blank()},{CompletedDate: Blank()}),
varCurrentRecord
)

Submit Button on EditForm1 Screen =

 

SubmitForm(EditForm1)

 

 

On one app this creates the desired results of copying an item and making a new request. But on the other I get a Error =

Network error when using Patch function: The specified column is generated by the server and can't be specified.

 

I tried the process of elimination by removing each of the patch to blank items and it seems to be the ID that is causing the issue.

 

Anyone have any troubleshooting steps I could use to help find out why this error keeps popping up?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SenoirB
Advocate I
Advocate I

I figured it out, I had mistakenly added the 'Created By' card to the form and turned the Visibility off on it. 😖 I was using it's value to prefill another section in the app. I removed that card from the form and its working as it should now.

View solution in original post

6 REPLIES 6
Drrickryp
Super User
Super User

@SenoirB 

The error message is because you have specified an ID where SharePoint generates its own ID.  Take out ID:Blank()} 

But if I don't blank the ID I'm only editing the record that I am trying to duplicate. By blank the ID, Sharepoint is supposed to create a new record from what (I thought) I understood.

Drrickryp
Super User
Super User

@SenoirB 

Nope.  If you want to add a blank new record to a second data source simply Collect(list2, Defaults(list2)) and SharePoint will add the ID. 

If you want to copy an existing record to the second data source, Collect(list2,ThisItem), If you want to specify only certain columns you can put them in the {...} part of the Collect() function like

Collect( IceCream, { Flavor: "Strawberry", Quantity: 300 } ) 

 

Thanks for the comments but my post may have been confusing. I was stating that both apps use the same Sharepoint data source. App 1 has no problems using the above formulas and submitting a new (copied) record. While App 2, using the exact same data source and formulas above, gives me the error. This is where I got the formulas from. Which looks like @RandyHayes may have helped come up with. I have successfully used this guide on 3 other apps as well. But for whatever reason I can't get it to submit for App 2, just the error. I must have a variable interfering or something.

SenoirB
Advocate I
Advocate I

I figured it out, I had mistakenly added the 'Created By' card to the form and turned the Visibility off on it. 😖 I was using it's value to prefill another section in the app. I removed that card from the form and its working as it should now.

Drrickryp
Super User
Super User

Putting me on.gif

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,161)