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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Invalid error type# Invalid ownerIdType = 10076 in dynamics crm 2016

(0) ShareShare
ReportReport
Posted on by 67

Hello Friends,

I am currently on dynamics crm 2016 onpremise

Got a task to create a record in one entity using console application and this entity contains reference keys with contact entity and other entities.

Below is my code

OrganizationServiceContext context = new OrganizationServiceContext(xrmProxy);
Entity insertCommPref = new Entity("*******");
insertCommPref["xxx_contactid"] = contactID;
insertCommPref["xxx_communicationpreferenceid"] = CommPreferenceID;
insertCommPref["createdon"]=DateTime.Now;
insertCommPref["createdby"]= CreatedBy;
insertCommPref["modifiedon"] =DateTime.Now;
insertCommPref["modifiedby"] = CreatedBy;
insertCommPref["owneridtype"] = 8;
insertCommPref["ownerid"] = new EntityReference("xxx_contactcommunicationpreference", ownerid);

insertCommPref["owningbusinessunit"] = new EntityReference("xxx_contactcommunicationpreference", owningBusinessUnit);
insertCommPref["statecode"] =0;
insertCommPref["statuscode"] =1;
insertCommPref["versionnumber"] =null;
insertCommPref["cpa_consentgiven"] =true;
xrmProxy.Create(insertCommPref);

Owneridtype is a int datatype and I am passing integer value but this is throwing exception "Invalid ownerIdType = 10076"

Can someone help me here please.

I have the same question (0)
  • Suggested answer
    Modesto Iacopino Profile Picture
    Microsoft Employee on at

    Hello,

    I think you specified some fields wrongly.

    For example the owneridtype equals 8, means that the owner is an user, but in the line after:

    insertCommPref["ownerid"] = new EntityReference("xxx_contactcommunicationpreference", ownerid);

    You are telling that the owner is instead not a user ( objectypecode equals 8 ) but a "xxx_contactcommunicationpreference" ( that I think is your custom entity with objecttypecode equals to 10076 )

    Look at the following:

    docs.microsoft.com/.../microsoft.xrm.sdk.entityreference

    Also the property insertCommPref["owningbusinessunit"]  need to be a Business Unit.

    Correct your code and check again.

    Regards

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 Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 55 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 37

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans