Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

CRM 2011 - How do you create a customer address entity record?

$
0
0

I have a plug-in that attempts to create a customeraddress record. The parent of the customeraddress is an account. The below returns an exception. Please help!

        private static void CreateAddvantageAddress(IOrganizationService service, Guid id)
        {
            using (var crm = new XrmServiceContext(service))
            {
                var account = crm.AccountSet.Where(
                    a => a.AccountId == id).First();

                var customeraddress = new CustomerAddress
                {
                    ParentId = account.ToEntityReference(),
                    ObjectTypeCode = "1",
                    AddressTypeCode = 920000001,
                    Name = "AdVantage Address"
                };

                crm.AddObject(customeraddress);
                crm.SaveChanges();
            }
        }


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>