Search code examples
salesforceepiserver

Where is Episerver Salesforce connector configuration saved?


Working with a site running Episerver with the Salesforce add-on to tie episerver forms to Salesforce. I enter username/password/token for my salesforce user in the salesforce connector configuration screen in episerver backend and it saves my credentials. I navigate to forms and can now see my salesforce fields to map the form fields to.

The issue is that the salesforce connection config keeps disappearing. After some time when returning to the salesforce connector config in the episerver admin, or going to a form and attempting to map fields, the salesforce connection is gone and my fields are no longer mapped. If I re-add the connection the field mappings return. Where is this configuration saved in the database and what could be causing it to overridden? Is there a way to configure default values in a web config instead?

Relevant Package Details:

EPiServer.CMS - v11.11.3

EPiServer.MarketingAutomationIntegration.Salesforce - v4.2.0

EPiServer.Marketing.Automation.Forms - v2.1.0

EDIT: It looks like the salesforce connector setting gets saved to dbo.tblBigTable and dbo.tblBigTableReference. Those records get cleared on startup of the project when I run it locally, still not sure why. I can restart the dev server without these records being cleared: Running something like the following shows where the connector name portion is saved. There are likely other entries in these tables for the other fields configured there.

select * from dbo.tblBigTable where String01 like '%my-connector-name%'
StoreName | ItemType | String01 | String02
Marketing_Automation_Connector_Credentials |
Episerver.Marketing.Connector.Framework.Data.ConnectorCredentialStoreData, Episerver.Marketing.Connector, Version=5.4.0.0, Culture=neutral, PublicKeyToken=null |
my-connector-name | 
!!=!encrypt!=!!0...

select * from dbo.tblBigTableReference where StringValue like '%my-connector-name%'

Type | PropertyName | CollectionType | ElementType | StringValue

3 | ActiveConnectors | 
System.Collections.Generic.Dictionary`2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.Object, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 | 
System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 | 
my-connector-name

Solution

  • Cause of issue:

    I ended up having to decompile Episerver's source code to find the issue. It turns out the issue is in EPiServer's Episerver.Marketing.Connector.Framework.MarketingConnectorManager.GetConnectorCredentials method, so this might not be specific to the Salesforce connector but any marketing connector. The problem is that when the credentials were created in our DEV environment they get encrypted in the database. When the credentials are then fetched later on in our Local instance there is an attempt to decrypt the credentials. If the credentials cannot be decrypted, EPiServer deletes them rather than throwing an error or saying no valid credentials found.

    Workaround:

    To get around this problem, you can add a machineKey tag to your web.config so that the decryptionKey is shared between local and dev environments:

    <system.web>
            <machineKey validationKey="YOUR_VALIDATION_KEY_HERE" decryptionKey="YOUR_ENCRYPTION_KEY_HERE" validation="SHA1" decryption="AES" />
            ....
    </system.web>