Skip to main content
Question

Not able to save Child object ContactLocation.Address

  • May 12, 2025
  • 0 replies
  • 37 views

Hi,

 

I am trying to save CustomerLocation including LocationContact.Address, the CustomerLocation gets saved but not the child object LocationAddress. I am using PUT.

how to save CustomerLocation with Child object LocationContact.Address?


 

var customerLocation = new CustomerLocation
 {

        AddressOverride = new BooleanValue { Value = false },
     ContactOverride = new BooleanValue { Value = true },


     Customer = new StringValue { Value = accountingData[0].EntityId.ToString() },
     LocationID = new StringValue { Value = accountingData[0].Addressid.ToString() },

     LocationName = new StringValue { Value = accountingData[0].Addressline1.ToString() },

     LocationContact = new Contact(),
     Active = new BooleanValue() { Value = true },


 };

 customerLocation.LocationContact.Address = new Address()
 {
     AddressLine1 = new StringValue { Value = accountingData[0].Addressline1.ToString() },
     AddressLine2 = new StringValue { Value = string.IsNullOrEmpty(accountingData[0].Addressline2) ? string.Empty : accountingData[0].Addressline2 },
     City = new StringValue { Value = string.IsNullOrEmpty(accountingData[0].City) ? string.Empty : accountingData[0].City.ToString() },
     Country = new StringValue { Value = string.IsNullOrEmpty(accountingData[0].CountryCode) ? string.Empty : accountingData[0].CountryCode },
     PostalCode = new StringValue { Value = string.IsNullOrEmpty(accountingData[0].Zip) ? string.Empty : accountingData[0].Zip },
     State = new StringValue { Value = string.IsNullOrEmpty(accountingData[0].Statecode) ? string.Empty : accountingData[0].Statecode },

 };