﻿#### 

## Contact List

While EXM for Sitecore 9 is yet to be released, it’s worth mentioning some improvements introduced in Sitecore 9 for Contact Lists. If you had luck to deal with EXM and contact lists in Sitecore 8.1, you should be familiar with challenges updating contact lists programmatically, list locks, subscribing contacts in scaled environments.

 Thanks to xConnect all Contact List issues are left behind.

xConnect serves as a service layer for real time contact changes, is scalable and accessible from all [core roles](https://doc.sitecore.net/developers/server-role-configuration-reference/core-roles/ "Sitecore core roles"). In Sitecore 9 contact subscription is stored in a similar way as part of Contact facets. The name for the facet has changed to **ListSubscriptions**. 

Updating contact subscription is a matter of updating contact facet and can be done using the following code. Changes will take place immediately.

```
   
    Guid listId = Guid.Parse("01b28284-4bff-456f-eb1a-f1e28db6edf6");
    Guid contactId = Guid.Parse("BEC76A9E-F958-0000-0000-0520EB67E0F0");
 
    using (XConnectClient client = GetClient())
    {
        Contact contact = client.Get<Contact>(
            new ContactReference(contactId),
            new ContactExpandOptions(new string[1] { "ListSubscriptions" })
        );

        contact.SetListSubscriptionsFacet(client, listId);
 
          client.Submit();
    }
                          
```

## Segmented Lists

 New xConnect based conditions available out of the box.

In Sitecore 8.x we had very limited list of segmentation conditions available out of the box. The following image illustrates almost all of them in one screen.

![sitecore 9 rule manager](https://www.brimit.com/-/media/images/blog/sc9listmanagerchanges1.png?la=en&amp;hash=1402A44AE4B480A56C5838B8982B4E42)

Now let’s see what conditions are available out of the box in Sitecore 9.0. The number of new conditions has increased significantly.

![sitecore 9 create rule](https://www.brimit.com/-/media/images/blog/sc9listmanagerchanges2.png?la=en&amp;hash=F121CC0942B18A567CCB34BED538C678)

There are conditions based on GeoIP; device, contact has used before; Marketing Automation enrollment; campaigns; channels; contact visits behavior like “Contact internal search keyword compared to specific value”. Think of Email campaign to introduce new BMW 5 Series Gran Turismo to all contacts who searched for keyword “family car” in the past.

 Consider how many new segmentation scenarios marketers can explore with Sitecore 9 out of the box!

The implementation for custom segmentation conditions has changed.

In short, in Sitecore 8.2 we would have to add the data required for segmentation condition to search index as **IComputedIndexField**, and implement condition by inheriting from **TypedQueryableOperatorCondition** or **TypedQueryableStringOperatorCondition**. 

[This post](http://robearlam.com/blog/list-all-sitecore-contacts-that-have-completed-a-goal/ "contact goals") demonstrates implementation for Sitecore 8 based condition like: **where contact triggered a specific goal**.

In Sitecore 9 in contrary such condition is available out of the box! Sneak picking the implementation we find **IContactSearchQueryFactory** interface is introduced to support predicates expression. The following code snippet illustrates implementation for such condition:

```
   
  public class GoalMatches : ICondition, IMappableRuleEntity, IContactSearchQueryFactory
  {
    public Guid DefinitionId { get; set; }
 
    public bool Evaluate(IRuleExecutionContext context)
    {
    Contact contact = context.Fact();
    if (contact.Interactions == null)
        return false;
    return contact.Interactions.Any(i => i.Events.OfType().Any(goal => goal.DefinitionId == this.DefinitionId));
    }
 
    public Expression< />> CreateContactSearchQuery(IContactSearchQueryContext context)
    {
        return contact => contact.InteractionsCache().InteractionCaches.Any(i => i.Goals.Any(goal => goal.DefinitionId == this.DefinitionId));
    }
  }

```

Notice the above condition also implements **ICondition** interface that requires **Evaluate()** method. Any condition that implements **ICondition** interface can be used as personalization rule and marketing automation condition. Both interface implementations use xConnect API. Wonderful Sitecore 9 documentation [provides more details](https://doc.sitecore.net/developers/xp/segmentation/predicates-overview.html "condition interfaces") on each type of condition interfaces.

 Previously used conditions are absent; refactoring is required in the event of upgrade from 8.x to 9.x

The definition item for the exact same condition like “where Job Title compares to” has different ids. The old 8.x conditions from **Segment Builder** group are not available in version 9.0 anymore, which brings us to a challenge: **segmented lists will require migration during upgrade**.

A reasonable question comes in mind whether or not a custom segmentation condition implemented in Sitecore 8.x will work in 9. The answer is: No. The good news is that implementation is similar and we can still use search predicates expression on contact facets and now in Sitecore 9 also on interactions.

Fly high with Sitecore 9.

##### Do you need help with your Sitecore project?

      ![](~/media/CD37043DFD1F491D8E92958A11959F75.ashx?la=en&amp;hash=D08B252DD3B41C09B588007541E5D22F)

   [VIEW SITECORE SERVICES](https://www.brimit.com/expertise/sitecore-cms)

###### Author

[!\[Alexei Vershalovich\](https://www.brimit.com/-/jssmedia/feature/blogs/authors/alexei-vershalovich-brimit---500.png?h=1098&amp;iar=0&amp;w=1042&amp;hash=7551A887E43E4DDE95E9C95102DBDF1B)
Alexei Vershalovich
Principal Consultant, digital experience and e-commerce](https://www.brimit.com/blog/author?authors=Alexei%20Vershalovich)

#### More on Sitecore

[!\[How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2024/vercel_cover-image.png)
#Guides#How-toDXPE-commerce
##### How Vercel Will Help You Save Effort When Deploying Sophisticated Sitecore Projects
Optimize and accelerate the development and deployment of complex multisite Sitecore projects.
Alexei Vershalovich on July 17, 2024](https://www.brimit.com/blog/how-vercel-will-help-you-save-effort-when-deploying-sophisticated-sitecore-projects)

[!\[Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2023/sitecore-mentoring---cover-image.png)
#How-toDXP
##### Training Up Tomorrow's Sitecore MVPs: a Mentoring Success Story
How to participate in the Sitecore Mentor program and help younger colleagues jump-start a career in Sitecore development.
Sergey Baranov on October 2, 2023](https://www.brimit.com/blog/training-up-tomorrows-sitecore-mvps)

[!\[Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)\](https://www.brimit.com/-/jssmedia/project/brimit/blog/2022/headless/adobestock_456986731.jpg)
#How-toDXPE-commerce
##### Going Headless. Part 2: When a Headless CMS Is Your Best Bet (if you have Sitecore)
Discover how a headless CMS can benefit organizations that use Sitecore.
Daniil Raschupkin, Palina Trokhautsava on September 15, 2022](https://www.brimit.com/blog/going-headless-part-2-when-a-headless-cms-is-your-best-bet-if-you-have-sitecore)

![](https://bat.bing.net/action/0?ti=187017043&amp;tm=gtm002&amp;Ver=2&amp;mid=c82a026d-c540-4687-bc6c-c8ec2dc9db84&amp;bo=2&amp;gtm_tag_source=1&amp;pi=0&amp;lg=en-US&amp;sw=800&amp;sh=600&amp;sc=24&amp;nwd=1&amp;tl=Sitecore%209%20List%20Manager%20changes&amp;kw=Sitecore,%20Sitecore%209,%20%20List,%20Manager,%20changes,%20contact,%20goal,%20list&amp;p=https%3A%2F%2Fwww.brimit.com%2Fblog%2Fsitecore-9-list-manager-changes&amp;r=&amp;lt=328&amp;evt=pageLoad&amp;sv=2&amp;asc=D&amp;cdb=AQAY&amp;rn=572426)