SmartConnect 2018

Salesforce Change Data Source Objects

The following objects are created to facilitate the processing of change data source maps from Salesforce:

 

Change table:

The change table is used to maintain the list of that changes within Salesforce. It is defined as follows:

Object Name: eOneCh_<EntityName>

API Name: eOneCh_<EntityName>__c

Label: Change tracking for <Entity Name>

 

Fields:

Field

API Name

Data Type

Remarks

Sequence

Name

Autonumber

Sequence number for the change table.

Action

Action__c

Picklist

Used to store the action that triggers the data source (insert, update)

Date Processed

DateProcessed__c

Date/Time

The date the processed flag was changed to true.

Linked Record

Link__c

Lookup

Used to link the change record with the changed entity record.

Map

Map__c

Text(255)

Used to store the map id that will use this change record.

Processed

Processed__c

Checkbox

False means record has not been processed by SmartConnect, true means record has been processed by SmartConnect.

External Sequence

Sequence__c

Autonumber (External)

External Sequence Id, used to access the record to update the processed status.

 

 

Apex triggers:

The following apex trigger is created for each entity / action combination required for change data sources:

Real time data source trigger

// where <entity> is the entity triggering the real time data source

// where <action_initial> is i for insert and u for update

// where <action> is insert or update depending on requirements

// where <mapid> is the map to process the change

trigger eOneCh_<mapid>_tr_<action_initial> on <entity> (before <action>) {

 set<ID> ids = Trigger.newMap.keyset();

 for(ID id : ids) {

         eOneCh_<entity>__c change = new eOneCh_<entity>__c();

         change.Action__c = '<action>';

         change.Link__c = id;

         change.Processed__c = false;

         change.Map__c = '<mapid>';

         insert change;

 }

}

 

// for example the trigger for a change data source triggered by account updates for a map SF_CHANGE would be

trigger eOneCh_SF_CHANGE_tr_U on Account (before update) {

 set<ID> ids = Trigger.newMap.keyset();

 for(ID id : ids) {

         eOneCh_Account__c change = new eOneCh_Account__c();

         change.Action__c = 'update';

         change.Link__c = id;

         change.Processed__c = false;

         change.Map__c = 'SF_CHANGE';

         insert change;

 }

}