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

Create a Contact entity through an entity collection

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

The SuperOffice.CRM.Entities namespace exposes entity collections such as ContactCollection and PersonCollection. It is therefore possible to create a Contact entity and assign it to the collection and thereby saving the collection the Contact entity will be saved.

Code

using SuperOffice.CRM.Entities;
using SuperOffice.CRM.Rows;
using SuperOffice;
using(SoSession mySession = SoSession.Authenticate("sam", "sam"))
{
  //Create a Contact Row
  Contact newContact = Contact.CreateNew();
  //Setting the Defaults for the Contact
  newContact.SetDefaults();
  //Assigning values for the individual properties of the ContactEntity
  //Assigning basic properties to a Contact
  newContact.Name = "EuroCenter";
  newContact.OrgNr = "1234523";
  newContact.Number1 = "7412885";
  //Adding a Row type property to a Contact Entity
  newContact.Country = new CountryRow.IdxCountryId(40);
  //Creating Email Rows
  EmailRow eMail1 = EmailRow.CreateNew();
  eMail1.EmailAddress = "Frank@Hardy.com";
  eMail1.Description = "Frank first email";
  EmailRow eMail2 = EmailRow.CreateNew();
  eMail2.EmailAddress = "Frank@Hardy.com";
  eMail2.Description = "Frank second email";
  //Adding the created Row types to the Properties of Rows type to the Contact Entity
  newContact.Emails.Add(eMail1);
  newContact.Emails.Add(eMail2);
  //Assigning values to Properties of Entity Collection Types.
  Sale newSale1 = new Sale.IdxSaleId(10);
  Sale newSale2 = new Sale.IdxSaleId(20);
  newContact.Sales.Add(newSale1);
  newContact.Sales.Add(newSale2);
  //Instantiating a Contact Collection
  ContactCollection newConCol = ContactCollection.CreateNew();
  //Adding the Contact Entity to the Collection and Saving the Collection
  newConCol.Add(newContact);
  newConCol.Save();
}

Walk-through

In the above code, a Contact entity has been created, and then it has been assigned to the instantiated ContactCollection.

Then the collection has been saved like this:

newConCol.Add(newContact);
newConCol.Save();
In This Article
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top