Try our conversational search powered by Generative AI!

Jason Masterson
Jul 13, 2018
  4937
(4 votes)

Episerver Marketing Connectors

Creating multiple instances of the same connector

               There are cases where an organization has multiple logins into the same Marketing Automation system for different business units or different regions. With that in mind, the EPiServer Connect for Marketing Automation 5.0.0 package lets you configure multiple instances of a connector with different credentials that will act independently within the CMS. The initial implementation of this feature does not have a user interface so you have to configure the second instance of the same connector with code. The following example shows how to create a second instance of the same Marketing Connector.

Code:

SampleConnector connector = new SampleConnector(); 
connector.InstanceId = new Guid("C125E524-CEBF-4D5C-AC36-BDDA61647D0D"); // my static instance id
connector.Name = $"{connector.Name}_EastCoastRegion"; // set a unique name so you can distinguish it from the original

var manager = ServiceLocator.Current.GetInstance<IMarketingConnectorManager>();
var config = manager.GetConnectorCredentials(connector.Id.ToString(), connector.InstanceId.ToString());
if( config == null ) // doesnt exist, create it
{
    manager.SaveConnectorCredentials(new ConnectorCredentials()
    {
        ConnectorId = connector.Id,
        ConnectorInstanceId = connector.InstanceId,
        ConnectorName = connector.Name,
        CredentialFields = new Dictionary<string, object>() { { "CreateDate", DateTime.Now }, { "LastUpdated", DateTime.Now } }
    });
}
else
{
    config.CredentialFields.Remove("LastUpdated");
    config.CredentialFields.Add("LastUpdated", DateTime.Now);
    manager.SaveConnectorCredentials(config);
}

       The code checks for a second set of credentials with the Marketing Connector Manager class and the specified InstanceId. If the code does not find the credentials, it creates the credentials that indicate that the framework should create a second instance of the connector with the new credential values. The second set of credentials needs to have the same Connector Id guid of the Connector class that implements IMarketingConnector.

ConnectorCredentials Class

  • ConnectorId. A guid that indicates which connector the credentials should be used for
  • ConnectorInstanceId. A guid that specifies the instance of the connector. The default Admin Config pages for a connector use the ConnectorId guid as its instance guid, so a second instance for that connector should be a different value.
  • ConnectorName. The display name of the connector, used for display in dropdowns when selecting a connector in the CMS UI. Make it something that differentiates it from any other connector instance.
  • CredentialFields. A dictionary of field names and their corresponding values that are used to communicate with the connector endpoint. This varies by connector so you need to know the proper dictionary structure to create an instance that can communicate to the connector endpoint.
Jul 13, 2018

Comments

Please login to comment.
Latest blogs
Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog

The A/A Test: What You Need to Know

Sure, we all know what an A/B test can do. But what is an A/A test? How is it different? With an A/B test, we know that we can take a webpage (our...

Lindsey Rogers | Apr 15, 2024

.Net Core Timezone ID's Windows vs Linux

Hey all, First post here and I would like to talk about Timezone ID's and How Windows and Linux systems use different IDs. We currently run a .NET...

sheider | Apr 15, 2024

What's new in Language Manager 5.3.0

In Language Manager (LM) version 5.2.0, we added an option in appsettings.json called TranslateOrCopyContentAreaChildrenBlockForTypes . It does...

Quoc Anh Nguyen | Apr 15, 2024