Views: 1457
Number of votes: 3
Average rating:

Display all Opt-in processes in EPiServer Campaign Connector

By default, EPiServer Campaign Connector only displays opt-in processes of type Double

However, sometimes we want to display opt-in processes of other types (Single, Confirmed). We can easily achieve this by overriding the default behaviour.

Firstly, we need to create a class which inherits from the default OptinProcesseService, then override the GetAllowedOptInProcesses method:

public class CustomOptinProcessServive : OptinProcessService

    public override IEnumerable<SelectItem> GetAllowedOptInProcesses()
        // GetAllOptInProcesses() returns a list of all opt-in processes where each item is a Tuple<long, string, string>:
        // + Item1 is the Id of the optin process
        // + Item2 is the Name of the optin process
        // + Item3 is the Type of the optin process
        return GetAllOptInProcesses().Select(x => new SelectItem() { Text = x.Item2, Value = x.Item1 });


Then register the above class as the default implementation for IOptinProcessService:

context.ConfigurationComplete += (o, e) =>
    context.Services.AddTransient<IOptinProcessService, CustomOptinProcessServive>();

Now the Opt-in process drop-down will display all opt-in processes:

Oct 12, 2018

Please login to comment.