Skip to main content

Notifications

Announcements

No record found.

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.

  • Suggested answer
    Modesto Iacopino Profile Picture
    on at
    RE: Invalid error type# Invalid ownerIdType = 10076 in dynamics crm 2016

    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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 78 Super User 2025 Season 1

#3
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 72

Overall leaderboard

Product updates

Dynamics 365 release plans