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

How to set an interest on or off for a contact (services)

Some tooltip text!
• 1 minute to read
 • 1 minute to read

You can use web services to alter the selected status of an interest of a specific contact.

Code

using SuperOffice;
using SuperOffice.CRM.Services;

Console.Write("Please Enter the UserName :- ");
string userName = Console.ReadLine();

Console.Write("Please enter the password :- ");
string passWord = Console.ReadLine();
Console.WriteLine();

using (SoSession newSession = SoSession.Authenticate(userName, passWord))
{
  //Retrieve a Contact Entity using the Contact Agent
  ContactAgent newConAgt = new ContactAgent();
  ContactEntity newConEnt = newConAgt.GetContactEntity(10);

  //Retrieve all available Interests for a Contact
  SelectableMDOListItem[] newSelMdoLstItms = newConEnt.Interests;

  foreach(SelectableMDOListItem newSelMdoLstItm in newSelMdoLstItms)
  {
    //Changing the Selected status and displaying only the selected items
    if (newSelMdoLstItm.Selected)
      newSelMdoLstItm.Selected = false;
    else
    {
      newSelMdoLstItm.Selected = true;
      Console.WriteLine(newSelMdoLstItm.Name);
    }
  }

  Console.ReadLine();

  //Save the modified Contact Entity
  newConAgt.SaveContactEntity(newConEnt);
}

Walk-through

We have first retrieved a Contact entity using the ContactAgent. And then used its Interests property to retrieve the contact’s interests into a SelectableMDOListItem array.

Next, we iterate on the array and change its Boolean Selected property status. By using the SaveContactEntity method available in the Contact agent, we save the modifications made to the entity.

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