cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ArtK
Helper I
Helper I

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

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

 

 

2 REPLIES 2
FCGALLEG
Microsoft
Microsoft

Hi Artk, 

 

I was looking and we will need more info. Our recommendation will be open a support ticket in order we can analyze the issue and provide you a solution.

 

Thanks,

Javier

Hi, 

Create a new canvas app using the connector "Current Environment" and connect it to a Dynamics 365 Sales environment that has the sample data installed (or use another account record).    Add four buttons, create, drop, rename, patch.   Add my code bits to the buttons, you can step through the process.  Then patch will fail as I have indicated.

 

I didn't get a response here so I also posted it here.  You can see other steps we have tried to resolve this.

https://powerusers.microsoft.com/t5/Building-Power-Apps/Dataverse-Patch-Record-Create-Error-Attachme...

 

Thanks

-Art

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

Users online (75,252)