• Share
    • Twitter
    • LinkedIn
    • Facebook
    • Email
  • Feedback
  • Edit
Show / Hide Table of Contents

Update a person with a new name, address, position using rows

Some tooltip text!
• 2 minutes to read
 • 2 minutes to read

Now let's focus on how we can update the person's name, position, and address using rows.

Code

The following example uses rows exclusively.

using SuperOffice.CRM.Rows;
using SuperOffice;
using(SoSession mySession = SoSession.Authenticate("SAL0", ""))
{
  // retrieve the person row that we want to change
  PersonRow myPersonRow = PersonRow.GetFromIdxPersonId(17);

  // change the first name and the last name
  myPersonRow.Firstname = "John";
  myPersonRow.Lastname = "White";

  // change the position here we have to know the position number we want to change to
  myPersonRow.PositionIdx = 1;

  // save the person row
  myPersonRow.Save();

  // retrieve the address of the person using the address type and the person id
  AddressRow personAddressRow = AddressRow.GetFromIdxAtypeIdxOwnerId(SuperOffice.Data.AddressType.PersonPrivateAddress, 17);

  // change the address
  personAddressRow.Address1 = "No: 73";
  personAddressRow.Address2 = "West Gate Street";
  personAddressRow.Address3 = "Lexington";
  personAddressRow.City = "Kentucky";

  // save the address row
  personAddressRow.Save();
}

Walk-through

We use the person row to change the name and the position of the person. Here we have assumed that we know the position ID of the position row that we want so we simply give that ID as the person’s position ID.

We changed the address of the person using an address row independent of the person row. Here we have retrieved the address row of the person using the address type and the person ID so we know that this is the address that was assigned to this person.

We have to save the person row and the address row separately since they are 2 different objects.

© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top