Does anyone have examples on, how to create list, add items to List Manager programatically?

  • how to get list by name, if not there then add it Aug 27 '17 at 9:13

There are 2 types of lists: Contact List and segmented list, each one has its own class to handle them.

You need a reference to: Sitecore.ListManagement.ContentSearch.dll

Contact List

//Get the manager
var listManager = Sitecore.Configuration.Factory.CreateObject("contactListManager", false) as ContactListManager;

//Create a list
ContactList list =  new ContactList()
    Name = name,
    Description = description,
    ParentId = new ID(parentId)

//Move the list to a folder (its parent)
listManager.MoveList(list.Id, list.ParentId.ToString());

//Finding a list by ID.
var list = listManager.FindById(listId);

Segmented List Manager

var segmentedListManager = Sitecore.Configuration.Factory.CreateObject("segmentedListManager", false) as SegmentedListManager;

All the other methods are the same.

These are the most basic operations you can do with lists, let me know if you need to do something else.

  • Which dll has this class ContactList?
    – Durga Bose
    Jun 10 '18 at 15:08
  • I have updated the answer: Sitecore.ListManagement.ContentSearch.dll Jun 13 '18 at 10:18
  • 1
    In later versions it's Sitecore.ListManagement.dll Jun 13 '18 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.