web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Duplicating Item From ...
Power Apps
Suggested Answer

Duplicating Item From Collection to SharePoint list DYNAMICALLY

(0) ShareShare
ReportReport
Posted on by 64
Hello,
 
I need to create a duplicate of a record in my collection as a new SP list item. I would prefer to do this without manually listing out all of the fields as that would break the functionality if any new fields were ever added. My issue is that when Patching of Collecting to the SP List, I get an error that 'Column 'Author#Claims' is generated by the server and can't be specified.'. But as you can see from my code, I am removing the Author column. If I try to add 'Author#Claims' to the list of columns to remove, it says that column doesn't exist. I also checked by converting the NewItem object to a JSON and there is no Author fields at all.
 
UpdateContext(
    {
        NewItem: Patch(
            DropColumns(
                SelectedPromoItem,
                ID,
                '{TriggerWindowStartToken}',
                '{TriggerWindowEndToken}',
                OData__ColorTag,
                '{ModerationStatus}',
                'ComplianceAssetId',
                '{FilenameWithExtension}',
                '{FullPath}',
                '{HasAttachments}',
                '{Identifier}',
                '{IsFolder}',
                '{Link}',
                '{Name}',
                '{Path}',
                '{Thumbnail}',
                '{VersionNumber}',
                'Author',
                Created,
                Editor,
                Modified,
                '{Attachments}',
                '{ModerationComment}'
            ),
            {'PromoActivity': Today() & " - " & UserProfile.displayName & " - " & "Copied From PromoID: " & SelectedPromoItem.ID}
        )
    }
);
Collect(
    'Promotion Planning',
    NewItem
);
This also doesn't work with the Patch and Defaults() argument.
 
Finally, I tried this:
Collect(
    'Promotion Planning',
    Defaults('Promotion Planning')
);
Patch(
    'Promotion Planning',
    Last('Promotion Planning'),
    NewItem
);
 
But then get the column 'Broker#Id' is read-only and can't be modified. Broker is a choice column in this list and I checked the JSON of this NewItem and see that Broker only includes Broker: {Value: "brokerval"}. 
 
So I am about to give up and just manually populate all of the columns and hope my org never updates this SP list, but this is kind of crazy to me that this is even this difficult. Can anyone shed some light on this functionality?
  • Suggested answer
    ronaldwalcott Profile Picture
    3,914 Moderator on at
    Did you try
    Patch(SelectedPromoItem, Defaults(SelectedPromoItem), theUpdateRecord)
     
    What fields are in your collection compared to the SharePoint list?
  • Suggested answer
    LessCodePaths Profile Picture
    100 on at
    Hi,
     
    If i would to archive that, I would definitely use ShowColumns instead of DropColumns - you can specify only the columns which are editable.
    But of course if you create new columns in the feature, you must add them to your collection.
    I think it is not a problem, since you have to set some values for them :)
     
    UpdateContext(
        {
            NewItem: Patch(
                ShowColumns(
                    SelectedPromoItem,
                    "Title", // Add only the fields you want to keep
                    "Discount",
                    "ExpiryDate",
                    "PromoType"
                ),
                {
                    PromoActivity: Today() & " - " & User().FullName & " - " & "Copied From PromoID: " & SelectedPromoItem.ID
                }
            )
        }
    );
    Collect(
        'Promotion Planning',
        NewItem
    );
    
     
    I have done it many times this way.
     
    L.
     
     
     
  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at
    LessCodePaths is correct (except quotes are not needed around the parameters). DropColumns is far from "future-proof" as any SharePoint system/version changes to the list field structure will immediately break it - the other issue is that it does not always work on "system" columns - which may be the case with your problem.
  • Suggested answer
    LessCodePaths Profile Picture
    100 on at
    Yeah,
     
    thank you WarrenBelz for correction - the quotes shouldn't be there.
    Here is corrected formula:
    UpdateContext(
        {
            NewItem: Patch(
                ShowColumns(
                    SelectedPromoItem,
                    Title, // Add only the fields you want to keep
                    Discount,
                    ExpiryDate,
                    PromoType
                ),
                {
                    PromoActivity: Today() & " - " & User().FullName & " - " & "Copied From PromoID: " & SelectedPromoItem.ID
                }
            )
        }
    );
    Collect(
        'Promotion Planning',
        NewItem
    );
    L.
  • AaronBastian Profile Picture
    64 on at
    @LessCodePaths
     
    As I stated in the post, I am aware you can do this, but this does not solve my issue as this is not dynamic. My point is that I do not want to have to explicitly specify all of the columns because if there is ever some need to add or remove columns from the sharepoint list for whatever reason, the copy functionality would break. I will need to very well document that this is how I made this functionality so that any future developers will know.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard