Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans