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 / Dataverse Patch Record...
Power Apps
Unanswered

Dataverse Patch Record Create Error: {Attachments}: Field 'Id' is required.

(0) ShareShare
ReportReport
Posted on by 38

Any DV/CDS entity that has Notes enabled will fail to create records using a data set from a collection with the error {Attachments}: Field 'Id' is required. If Notes are not enabled, it works. If someone (e.g. customer) enables Notes on the entity you are using, after your Canvas app is installed, your app is now broken.

The only way to create records is to write a Patch command that specifies EVERY field you want. Doing that way makes the process painfully slow to create new records. It takes just under 30 PAINFUL minutes to create 300 individual records across six entities in a Canvas App.

Here is the sample code using the Account entity. I am trying to copy an existing record, change the account name and then create a new account record.

 

//get an account record(s)
ClearCollect(account_col, Filter(Accounts, name = "Adventure Works (sample)") );


//Remove server generated data fields to prevent server errors

//RANT: Why doesn't the server just ignore fields it is creating data for and just show a warning instead of failure?
ClearCollect(accountafterdrop_col, DropColumns(account_col,
"accountid",
"merged",
"opendeals",
"opendeals_date",
"opendeals_state",
"openrevenue_date",
"openrevenue",
"openrevenue_base",
"openrevenue_state",
"revenue_base",
"address1_composite",
"exchangerate",
"_ownerid_value",
"createdby",
"createdon",
"createdonbehalfby",
"importsequencenumber",
"modifiedby",
"modifiedon",
"modifiedonbehalfby",
"overriddencreatedon",
"owningbusinessunit",
"owningteam",
"owninguser",
"statecode",
"statuscode",
"timezoneruleversionnumber",
"utcconversiontimezonecode",
"versionnumber"
)
);


// rename/update account record(s) to be copied/created
UpdateIf(accountafterdrop_col, true, { name: "Test Account Created From Patch" } )


// create new account record(s)
ForAll(accountafterdrop_col As NewAccount,
Patch(Accounts, Defaults(Accounts) , NewAccount)
);


Patch Create Fail Error: {Attachments}: Field 'Id' is required.

Also tried: Patch(Accounts, accountafterdrop_col);
It fails with the same error too.

What modification is required to the collection "accountafterdrop_col" to make the Patch statements above work? Or any other ideas to fix this issue?

 

Thanks,

-Art

 

(Also posted this to ISV forum)

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtK ,

     

    Do you want to press a button to copy multiple records with attachments to the same table (remove some field values created by the system)?

     

    If my assumption is correct, first of all I think your formula has an error.

    You could try :

    ForAll(accountafterdrop_col As NewAccount,
    Patch(Accounts, Defaults(Accounts) , ThisRecord))

    instead of

    2.PNG

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

  • ArtK Profile Picture
    38 on at

    Hi,

     

    Using the "As" in the line above makes "NewAccount" the same as "ThisRecord".

     

    I tried your suggestion and it fails too, as expected.  See screenshot.

     

    ForAll(accountafterdrop_col ,
    Patch(Accounts, Defaults(Accounts) , ThisRecord)
    );

     

     

    AttachmentFieldRequired.png
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtK ,

     

    If the attachment function is enabled for the table, the attachments cannot be copied together when copying data in batches.

     

    So, please try this code:

    ClearCollect(accountafterdrop_col, DropColumns(account_col,
    "accountid",
    "merged",
    "opendeals",
    "opendeals_date",
    "opendeals_state",
    "openrevenue_date",
    "openrevenue",
    "openrevenue_base",
    "openrevenue_state",
    "revenue_base",
    "address1_composite",
    "exchangerate",
    "_ownerid_value",
    "createdby",
    "createdon",
    "createdonbehalfby",
    "importsequencenumber",
    "modifiedby",
    "modifiedon",
    "modifiedonbehalfby",
    "overriddencreatedon",
    "owningbusinessunit",
    "owningteam",
    "owninguser",
    "statecode",
    "statuscode",
    "timezoneruleversionnumber",
    "utcconversiontimezonecode",
    "versionnumber",
    
    "{Attachments}"
    )
    );

     

    instead of 

    2.PNG

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

  • ArtK Profile Picture
    38 on at

    Tried it.  Sadly, it doesn't work.   Error:  The specified column {Attachments} does not exist.

    When the collection is created from the Dataverse Account entity, there is no Attachment column displayed. 

     

    However, on the account_col I tried using AddColumns to add an "Attachments" column and the error said it already exists.  Then I tried to use DropColumns and drop the "Attachments" column (that isn't visible in the collection) and the error says the column doesn't exist.

     

     

    DropColumnsError-Attachments.png
  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtK ,

     

    I used the table ‘Test 888S’ to test.

    v-xiaochen-msft_3-1614239444625.png

     

     

    v-xiaochen-msft_1-1614239323738.png

     

    v-xiaochen-msft_2-1614239323741.png

     

    It worked here.

    Maybe the problem is related to the table?

    Are you using a table generated by the system?

     

    Best Regards,

    Wearsky

  • ArtK Profile Picture
    38 on at

    I am using the CDS "Account" entity which has been around since CRM version 1.0.  It has notes/attachments enabled.   I changed my formula editor to match yours, but there is no Attachments field listed.   You will have to use a Dynamics 365 Sales environment to test this.  In my app I am using the CDS connector "current environment".

     

    Thanks,

    Art

  • v-xiaochen-msft Profile Picture
    Microsoft Employee on at

    Hi @ArtK ,

     

    Unfortunately, I cannot use the environment(CRM) you mentioned for testing here.

    I suggest you change the way of batch update records instead of using dropcolumns() function.

     

    For example:

    ForAll(accountafterdrop_col ,
    Patch(Accounts, Defaults(Accounts) , {your column1:ThisRecord.***,your column2:ThisRecord.***,*********})
    );

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • ArtK Profile Picture
    38 on at

    Hi,

    What you suggest is the way I am doing it now.  It takes 30 minutes to create 300 records. This is way to long of a time.  If I use my way above on an entity that does not have notes enabled, creating 300 records takes just 2-3 minutes.   That is why I am trying to solve this.  I need to create batch records on entities that have notes enabled as well as ones that don't.

     

    Thanks for trying to help.

    -Art

  • TheSec Profile Picture
    58 on at

    Hello,

    I'm new to PowerApps and Sharepoint and therefore take the following with a grain of salt.

     

    The error message: Patch Create Fail Error: {Attachments}: Field 'Id' is required

    points to the fact that the field is a multi value field instead of a single value record.

     

    I other DB systems you would get the same error because to write a string into an array you have to provide the index (=position or ID). You have to pass table.my_field(0) = my_value instead of table.my_field = my_value to insert the first value.

     

    I tried to figure this out by showing the attachment field containing multiple attachments in a gallery and grab the Id-property, but it wasn't from expected type, but long string instead.

     

    Bildschirmfoto 2021-02-25 um 14.14.07.jpg

    Bildschirmfoto 2021-02-25 um 14.14.18.jpg

    These IDs get generated by the controls/frameworks and the way to use the "standard" fires them and does the trick of managing this for you but this takes of course longer than a "direct patch" on the raw table.

    As long it's not clear how to pass the Id for a multi-value field I fear you will not succeed in gaining the performance. 

     

  • TheSec Profile Picture
    58 on at

    I had a closer look on it. The synonym of a multi-value record should be a collection.

    So the way to store multi-value fields is to build a collection variable. Then you can patch a field by providing the variable instead of a string.

    In your case I'd try to build a collection of the image by reading it from another SP list and then patch like this:

     

    Patch(Accounts, Defaults(Accounts) , {column1: Column1, Attachment: varAttachmentCol.....})

     

    If you need no Attachment you might just read from an SP list where the attachment field is empty. This should just give you the empty structure. Hope this helps.  

     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 522

#2
WarrenBelz Profile Picture

WarrenBelz 437 Most Valuable Professional

#3
Vish WR Profile Picture

Vish WR 405

Last 30 days Overall leaderboard