UpdateCustomer - accountsIQ/API-Wiki GitHub Wiki

The UpdateCustomer function creates or updates a single Customer back to an entity.

Please take note of the create parameter when using this has it has an effect on results.

When updating, make sure to get new rowversion Customer on field as this changes after an update. To get an updated version on this field, please call GetCustomer and use the new rowversion in the update request

Declaration

C#

public WSResult2OfBoolean UpdateCustomer(string token, Customer customer, bool create)

Visual Basic

Public Function UpdateCustomer(ByVal token As String, ByVal customer As Customer, ByVal create As Boolean) As WSResult2OfBoolean

Parameter List

Parameter Type Description
token String The session token retrieved during authentication.
customer Customer The customer object to create/update.
create Boolean Flag indicating whether the system should create the customer code if it does not already exist. True: the customer is updated or created if it does not exist; False: the customer code can only by updated, not created.

Example

C#

Integration ws = new Integration();

String auth = ws.Login(entityID, partnerKey, userKey);
if (auth != null)
{
  WSResult2OfCustomer wscustomer = ws.GetCustomer(auth, "TESTINTEGR");
  Assert.IsNotNull(wscustomer);
  Customer customer = wscustomer.Result;
  Assert.IsNotNull(customer);

  customer.Name = "ABC Account 01 - update";
  customer.Address1 = "this is my address 1 - update";
  customer.Address2 = "this is my address 2 - update";
  customer.City = "this is my city - update";
  customer.County_State = "this is my county - update";
  customer.Country = "this is my country - update";
  customer.PostCode = "this is my postcode - update";
  customer.Contact = "Contact - update";
  customer.Email = "[email protected]";
  customer.Fax = "0123459";
  customer.Phone = "0123457";

  WSResult2OfBoolean result = ws.UpdateCustomer(auth, customer, false);
  Assert.IsNotNull(result);
  Assert.AreEqual(true, result.Result);

  wscustomer = ws.GetCustomer(auth, "TESTINTEGR");
  customer = wscustomer.Result;
  Assert.IsNotNull(customer);
  Assert.AreEqual("TESTINTEGR", customer.Code);
  Assert.AreEqual("ABC Account 01 - update", customer.Name);
  Assert.AreEqual("this is my address 1 - update", customer.Address1);
  Assert.AreEqual("this is my address 2 - update", customer.Address2);
  Assert.AreEqual("this is my city - update", customer.City);
  Assert.AreEqual("this is my county - update", customer.County_State);
  Assert.AreEqual("this is my country - update", customer.Country);
  Assert.AreEqual("this is my postcode - update", customer.PostCode);
  Assert.AreEqual("Contact - update", customer.Contact);
  Assert.AreEqual("[email protected]", customer.Email);
  Assert.AreEqual("0123459", customer.Fax);
  Assert.AreEqual("0123457", customer.Phone);

  customer.Name = "ABC Account 01";
  customer.Address1 = "this is my address 1";
  customer.Address2 = "this is my address 2";
  customer.City = "this is my city";
  customer.County_State = "this is my county";
  customer.Country = "this is my country";
  customer.Country = "this is my country";
  customer.PostCode = "this is my postcode";
  customer.Contact = "Contact";
  customer.Email = "[email protected]";
  customer.Fax = "0123489";
  customer.Phone = "0123456";

  result = ws.UpdateCustomer(auth, customer, false);
  Assert.IsNotNull(result);
  Assert.AreEqual(true, result.Result);

  wscustomer = ws.GetCustomer(auth, "TESTINTEGR");
  customer = wscustomer.Result;
  Assert.IsNotNull(customer);
  Assert.AreEqual("TESTINTEGR", customer.Code);
  Assert.AreEqual("ABC Account 01", customer.Name);
  Assert.AreEqual("this is my address 1", customer.Address1);
  Assert.AreEqual("this is my address 2", customer.Address2);
  Assert.AreEqual("this is my city", customer.City);
  Assert.AreEqual("this is my county", customer.County_State);
  Assert.AreEqual("this is my country", customer.Country);
  Assert.AreEqual("this is my postcode", customer.PostCode);
  Assert.AreEqual("Contact", customer.Contact);
  Assert.AreEqual("[email protected]", customer.Email);
  Assert.AreEqual("0123489", customer.Fax);
  Assert.AreEqual("0123456", customer.Phone);
}

Visual Basic

Dim ws As New Integration

Dim auth As String = ws.Login(entityID, partnerKey, userKey)
If (Not Me.auth Is Nothing) Then
  Dim wscustomer As WSResult2OfCustomer = Me.ws.GetCustomer(Me.auth, "TESTINTEGR")
  Assert.IsNotNull(wscustomer)
  Dim customer As Customer = wscustomer.Result
  Assert.IsNotNull(customer)
  customer.Name = "ABC Account 01 - update"
  customer.Address1 = "this is my address 1 - update"
  customer.Address2 = "this is my address 2 - update"
  customer.City = "this is my city - update"
  customer.County_State = "this is my county - update"
  customer.Country = "this is my country - update"
  customer.PostCode = "this is my postcode - update"
  customer.Contact = "Contact - update"
  customer.Email = "[email protected]"
  customer.Fax = "0123459"
  customer.Phone = "0123457"
  Dim result As WSResult2OfBoolean = Me.ws.UpdateCustomer(Me.auth, customer, False)
  Assert.IsNotNull(result)
  Assert.AreEqual(Of Boolean)(True, result.Result)
  customer = Me.ws.GetCustomer(Me.auth, "TESTINTEGR").Result
  Assert.IsNotNull(customer)
  Assert.AreEqual(Of String)("TESTINTEGR", customer.Code)
  Assert.AreEqual(Of String)("ABC Account 01 - update", customer.Name)
  Assert.AreEqual(Of String)("this is my address 1 - update", customer.Address1)
  Assert.AreEqual(Of String)("this is my address 2 - update", customer.Address2)
  Assert.AreEqual(Of String)("this is my city - update", customer.City)
  Assert.AreEqual(Of String)("this is my county - update", customer.County_State)
  Assert.AreEqual(Of String)("this is my country - update", customer.Country)
  Assert.AreEqual(Of String)("this is my postcode - update", customer.PostCode)
  Assert.AreEqual(Of String)("Contact - update", customer.Contact)
  Assert.AreEqual(Of String)("[email protected]", customer.Email)
  Assert.AreEqual(Of String)("0123459", customer.Fax)
  Assert.AreEqual(Of String)("0123457", customer.Phone)
  customer.Name = "ABC Account 01"
  customer.Address1 = "this is my address 1"
  customer.Address2 = "this is my address 2"
  customer.City = "this is my city"
  customer.County_State = "this is my county"
  customer.Country = "this is my country"
  customer.Country = "this is my country"
  customer.PostCode = "this is my postcode"
  customer.Contact = "Contact"
  customer.Email = "[email protected]"
  customer.Fax = "0123489"
  customer.Phone = "0123456"
  result = Me.ws.UpdateCustomer(Me.auth, customer, False)
  Assert.IsNotNull(result)
  Assert.AreEqual(Of Boolean)(True, result.Result)
  customer = Me.ws.GetCustomer(Me.auth, "TESTINTEGR").Result
  Assert.IsNotNull(customer)
  Assert.AreEqual(Of String)("TESTINTEGR", customer.Code)
  Assert.AreEqual(Of String)("ABC Account 01", customer.Name)
  Assert.AreEqual(Of String)("this is my address 1", customer.Address1)
  Assert.AreEqual(Of String)("this is my address 2", customer.Address2)
  Assert.AreEqual(Of String)("this is my city", customer.City)
  Assert.AreEqual(Of String)("this is my county", customer.County_State)
  Assert.AreEqual(Of String)("this is my country", customer.Country)
  Assert.AreEqual(Of String)("this is my postcode", customer.PostCode)
  Assert.AreEqual(Of String)("Contact", customer.Contact)
  Assert.AreEqual(Of String)("[email protected]", customer.Email)
  Assert.AreEqual(Of String)("0123489", customer.Fax)
  Assert.AreEqual(Of String)("0123456", customer.Phone)
End If

See Also

⚠️ **GitHub.com Fallback** ⚠️