> ## Documentation Index
> Fetch the complete documentation index at: https://docs.superoffice.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to set an interest on or off for a contact (data layer)

> How to set an interest on or off for a contact using entities

You can search for an [interest][1] and then set the interest to true or false. Here, we use the `ContactInterestHelper`.

## Code

```csharp CS theme={null}
using SuperOffice;
using SuperOffice.CRM.Entities;
using SuperOffice.CRM.Lists;

using (SoSession newSession = SoSession.Authenticate("sam", "sam"))
{
  //Setting the Interest name to be searched
  string searchIntrsName = "Sams Interests";

  //Retrieve a Contact
  Contact newContact= Contact.GetFromIdxContactId(10);

  //Search and find the contact interests by interest name
  ISoListItem newIntrstItm = newContact.InterestHelper.RootItems.Find(delegate(ISoListItem ISOLstItm)
  {
    return ISOLstItm.Name.Equals(searchIntrsName,StringComparison.InvariantCultureIgnoreCase);
  }
  );

  //Check whether the Interest has been found
  if (newIntrstItm != null && newIntrstItm.Id > 0)
  {
    //Sets the Interest to true or false
    newContact.InterestHelper.SetItemSelection(newIntrstItm.Id, true);
  }
}
```

## Walk-through

The `Find` method available through the `Contact` class's `InterestHelper.RootItems` can be used to make our search.

```csharp CS theme={null}
  ISoListItem newIntrstItm = newContact.InterestHelper.RootItems.Find(delegate(ISoListItem ISOLstItm)
  {
    return ISOLstItm.Name.Equals(searchIntrsName,StringComparison.InvariantCultureIgnoreCase);
  }
  );
```

The method returns an `ISoListItem` and requires a delegate that defines the element for which we should search to be passed into the method. The method then returns any interest that matches our search interest by using the `Equals` method.

Next, we move on to setting the interest to true or false. To do this we use the `SetItemSelection` method available `ContactInterestHelper` class. The method requires the interest ID and the new selection status (true or false) to be passed.

[1]: ../../../../company/dev/index#interests


## Related topics

- [How to set an interest on or off for a contact (services)](/en/api/web-services/howto/company/set-interest-on-off-services.md)
- [Interests](/en/automation/crmscript/howto/interests/index.md)
- [Get a contact through the services layer](/en/api/web-services/howto/company/get-contact-via-services-layer.md)
- [Set/clear interest on contact](/en/automation/crmscript/howto/interests/contact-interests.md)
- [How to add members to a static selection using entities layer](/en/api/search/selection/entity/add-member-to-static-selection-entities.md)
- [Set/clear interest on company](/en/automation/crmscript/howto/interests/company-interests.md)
- [Working with companies in API](/en/company/dev/index.md)
