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.