Programmatically create contact list
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I know how to programmatically add contacts to a contact list, either through the contact itself, or through the List Manager API:
xContact.SetListSubscriptionsFacet(xConnectClient, listId);
Source: https://www.brimit.com/blog/sitecore-9-list-manager-changes
var subscriptionService = serviceLocator.ServiceProvider.GetService<ISubscriptionService>();
subscriptionService.Subscribe(contactListId, contactId);
Source: https://doc.sitecore.net/sitecore_experience_platform/digital_marketing/the_list_manager/the_list_manager_api
But none of these services have anything on how to programmatically create a list. I can probably do it a dirty way by manually adding an item to /sitecore/system/Marketing Control Panel/Contact Lists
(based on Contact List
template), but if Sitecore needs to do some indexing or other things when creating lists, this will of course not be enough.
So how can I programmatically create a contact list?
Sitecore 9.0.2 (rev. 180604)
list-manager
add a comment |Â
up vote
1
down vote
favorite
I know how to programmatically add contacts to a contact list, either through the contact itself, or through the List Manager API:
xContact.SetListSubscriptionsFacet(xConnectClient, listId);
Source: https://www.brimit.com/blog/sitecore-9-list-manager-changes
var subscriptionService = serviceLocator.ServiceProvider.GetService<ISubscriptionService>();
subscriptionService.Subscribe(contactListId, contactId);
Source: https://doc.sitecore.net/sitecore_experience_platform/digital_marketing/the_list_manager/the_list_manager_api
But none of these services have anything on how to programmatically create a list. I can probably do it a dirty way by manually adding an item to /sitecore/system/Marketing Control Panel/Contact Lists
(based on Contact List
template), but if Sitecore needs to do some indexing or other things when creating lists, this will of course not be enough.
So how can I programmatically create a contact list?
Sitecore 9.0.2 (rev. 180604)
list-manager
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I know how to programmatically add contacts to a contact list, either through the contact itself, or through the List Manager API:
xContact.SetListSubscriptionsFacet(xConnectClient, listId);
Source: https://www.brimit.com/blog/sitecore-9-list-manager-changes
var subscriptionService = serviceLocator.ServiceProvider.GetService<ISubscriptionService>();
subscriptionService.Subscribe(contactListId, contactId);
Source: https://doc.sitecore.net/sitecore_experience_platform/digital_marketing/the_list_manager/the_list_manager_api
But none of these services have anything on how to programmatically create a list. I can probably do it a dirty way by manually adding an item to /sitecore/system/Marketing Control Panel/Contact Lists
(based on Contact List
template), but if Sitecore needs to do some indexing or other things when creating lists, this will of course not be enough.
So how can I programmatically create a contact list?
Sitecore 9.0.2 (rev. 180604)
list-manager
I know how to programmatically add contacts to a contact list, either through the contact itself, or through the List Manager API:
xContact.SetListSubscriptionsFacet(xConnectClient, listId);
Source: https://www.brimit.com/blog/sitecore-9-list-manager-changes
var subscriptionService = serviceLocator.ServiceProvider.GetService<ISubscriptionService>();
subscriptionService.Subscribe(contactListId, contactId);
Source: https://doc.sitecore.net/sitecore_experience_platform/digital_marketing/the_list_manager/the_list_manager_api
But none of these services have anything on how to programmatically create a list. I can probably do it a dirty way by manually adding an item to /sitecore/system/Marketing Control Panel/Contact Lists
(based on Contact List
template), but if Sitecore needs to do some indexing or other things when creating lists, this will of course not be enough.
So how can I programmatically create a contact list?
Sitecore 9.0.2 (rev. 180604)
list-manager
list-manager
asked 59 mins ago


GTHvidsten
1337
1337
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
For Sitecore 9.x, you need to go through the IDefinitionManager<IContactListDefinition>
e.g.:
var definitionManager = ServiceLocator.ServiceProvider.GetService<IDefinitionManager<IContactListDefinition>>();
definitionManager.SaveAsync(new ContactListDefinition(Guid.NewGuid(), "alias", culture, "name", DateTime.UtcNow, createdBy))
From
- Sitecore.Marketing.dll
add a comment |Â
up vote
1
down vote
Here is the code which allows to create a contact list programatically in Sitecore:
private Guid CreateContactList()
ContactListModel entity = new ContactListModel();
Guid guid = Guid.NewGuid();
entity.Id = guid.ToString();
entity.Type = ListType.ContactList.ToString();
entity.Name = "My new contact list";
IRepository<ContactListModel> contactListRepository = (IRepository<ContactListModel>) ServiceLocator.ServiceProvider.GetService(typeof(IRepository<ContactListModel>));
contactListRepository.Add(entity);
return guid;
Remember to add references to:
- Sitecore.ListManagement.Services.dll
- Sitecore.Marketing.dll
- Sitecore.Services.Core.dll
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
For Sitecore 9.x, you need to go through the IDefinitionManager<IContactListDefinition>
e.g.:
var definitionManager = ServiceLocator.ServiceProvider.GetService<IDefinitionManager<IContactListDefinition>>();
definitionManager.SaveAsync(new ContactListDefinition(Guid.NewGuid(), "alias", culture, "name", DateTime.UtcNow, createdBy))
From
- Sitecore.Marketing.dll
add a comment |Â
up vote
2
down vote
For Sitecore 9.x, you need to go through the IDefinitionManager<IContactListDefinition>
e.g.:
var definitionManager = ServiceLocator.ServiceProvider.GetService<IDefinitionManager<IContactListDefinition>>();
definitionManager.SaveAsync(new ContactListDefinition(Guid.NewGuid(), "alias", culture, "name", DateTime.UtcNow, createdBy))
From
- Sitecore.Marketing.dll
add a comment |Â
up vote
2
down vote
up vote
2
down vote
For Sitecore 9.x, you need to go through the IDefinitionManager<IContactListDefinition>
e.g.:
var definitionManager = ServiceLocator.ServiceProvider.GetService<IDefinitionManager<IContactListDefinition>>();
definitionManager.SaveAsync(new ContactListDefinition(Guid.NewGuid(), "alias", culture, "name", DateTime.UtcNow, createdBy))
From
- Sitecore.Marketing.dll
For Sitecore 9.x, you need to go through the IDefinitionManager<IContactListDefinition>
e.g.:
var definitionManager = ServiceLocator.ServiceProvider.GetService<IDefinitionManager<IContactListDefinition>>();
definitionManager.SaveAsync(new ContactListDefinition(Guid.NewGuid(), "alias", culture, "name", DateTime.UtcNow, createdBy))
From
- Sitecore.Marketing.dll
answered 17 mins ago


Jacob Nielsen
2,025526
2,025526
add a comment |Â
add a comment |Â
up vote
1
down vote
Here is the code which allows to create a contact list programatically in Sitecore:
private Guid CreateContactList()
ContactListModel entity = new ContactListModel();
Guid guid = Guid.NewGuid();
entity.Id = guid.ToString();
entity.Type = ListType.ContactList.ToString();
entity.Name = "My new contact list";
IRepository<ContactListModel> contactListRepository = (IRepository<ContactListModel>) ServiceLocator.ServiceProvider.GetService(typeof(IRepository<ContactListModel>));
contactListRepository.Add(entity);
return guid;
Remember to add references to:
- Sitecore.ListManagement.Services.dll
- Sitecore.Marketing.dll
- Sitecore.Services.Core.dll
add a comment |Â
up vote
1
down vote
Here is the code which allows to create a contact list programatically in Sitecore:
private Guid CreateContactList()
ContactListModel entity = new ContactListModel();
Guid guid = Guid.NewGuid();
entity.Id = guid.ToString();
entity.Type = ListType.ContactList.ToString();
entity.Name = "My new contact list";
IRepository<ContactListModel> contactListRepository = (IRepository<ContactListModel>) ServiceLocator.ServiceProvider.GetService(typeof(IRepository<ContactListModel>));
contactListRepository.Add(entity);
return guid;
Remember to add references to:
- Sitecore.ListManagement.Services.dll
- Sitecore.Marketing.dll
- Sitecore.Services.Core.dll
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Here is the code which allows to create a contact list programatically in Sitecore:
private Guid CreateContactList()
ContactListModel entity = new ContactListModel();
Guid guid = Guid.NewGuid();
entity.Id = guid.ToString();
entity.Type = ListType.ContactList.ToString();
entity.Name = "My new contact list";
IRepository<ContactListModel> contactListRepository = (IRepository<ContactListModel>) ServiceLocator.ServiceProvider.GetService(typeof(IRepository<ContactListModel>));
contactListRepository.Add(entity);
return guid;
Remember to add references to:
- Sitecore.ListManagement.Services.dll
- Sitecore.Marketing.dll
- Sitecore.Services.Core.dll
Here is the code which allows to create a contact list programatically in Sitecore:
private Guid CreateContactList()
ContactListModel entity = new ContactListModel();
Guid guid = Guid.NewGuid();
entity.Id = guid.ToString();
entity.Type = ListType.ContactList.ToString();
entity.Name = "My new contact list";
IRepository<ContactListModel> contactListRepository = (IRepository<ContactListModel>) ServiceLocator.ServiceProvider.GetService(typeof(IRepository<ContactListModel>));
contactListRepository.Add(entity);
return guid;
Remember to add references to:
- Sitecore.ListManagement.Services.dll
- Sitecore.Marketing.dll
- Sitecore.Services.Core.dll
answered 25 mins ago


Marek Musielak
8,38311033
8,38311033
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f14753%2fprogrammatically-create-contact-list%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password