cancel
Showing results for 
Search instead for 
Did you mean: 

How to update individual customer information in the SDK

koliosis
Explorer
0 Kudos
158

Hello experts. I'm trying to update individual customer information through the sdk. Here's the current set of code that I'm using:

var updateCustomer = Customer.Retrieve(existingCustomer.InternalID);
var existingAddressInfo = updateCustomer.AddressInformation.GetFirst();
var existingAddress = existingAddressInfo.Address;
var existingEmail = existingAddress.DefaultEMail;

var updateCustomerCustomerCommon = updateCustomer.CurrentCommon;
var updateCustomerAddressInfo = updateCustomer.AddressInformation.Create();
var updateCustomerAddress = updateCustomerAddressInfo.Address;

// update address
var defaultemailbo = updateCustomerAddress.DefaultEMail;
if (!defaultemailbo.IsSet()) {
    defaultemailbo = updateCustomerAddress.DefaultEMail.Create();
}
var email = updateCustomer.AddressInformation.Address.DefaultEMail.GetFirst();
defaultemailbo.URI.content = this.Email.content;

// update phone
var defaultphonebo = updateCustomerAddress.DefaultConventionalPhone;
if (!defaultphonebo.IsSet()) {
    defaultphonebo = updateCustomerAddress.DefaultConventionalPhone.Create();
}
defaultphonebo.FormattedNumberDescription = "+" + this.Home_Phone;


// Update address
var address = updateCustomerAddress.DefaultPostalAddressRepresentation;
if (!address.IsSet()) {
    address = updateCustomerAddress.DefaultPostalAddressRepresentation.Create();
}
address.CountryCode = updateCustomerCustomerCommon.Person.NationalityCountryCode;
address.RegionCode.content = region;
address.CityName = this.City;
address.StreetName = this.Addr;
if (this.Postal_Code.IsInitial()) {
    address.StreetPostalCode = "00000";
} else {
    address.StreetPostalCode = this.Postal_Code;
}
address.AdditionalHouseID = this.Addr2;
}

The individual customer is updating but the text on the individual customers account isn't reflecting the change:

koliosis_0-1727886420057.png

How do I update the text in the details tab through the SDK? Thanks in advance.

View Entire Topic
LewisTPeters
Discoverer
0 Kudos

Hi,

I don't know if it's still relevant, but it used to be that sometimes trying to write information using those shortcut variables didn't work so you had to specify the full path. What I suggest is:

updateCustomer.AddressInformation.Address.DefaultEMail.URI.content = <new email>;

That might work for you.

Lewis