Synchronizing Source and Target Records

Checklist

To synchronize source and target records:

Steps  
1 Ensure that Sync Enabled is selected in the ClickLink Settings custom setting. See Activating and Deactivating Synchronization.
2 Add a lookup field on the target header object that points back to the source header object.
3 Create a mapping in your ClickLink header rule that maps the source header object's ID field to the lookup field in the target object that you created in the previous step.
4 Add a lookup field on the target detail object that points back to the source line object.
5 Create a mapping in your ClickLink detail rule that maps the source detail object's ID field to the lookup field in the target detail object that you created in the previous step.
6 Create a checkbox field on the target header object with the name: IsSyncing__c.
7 Create a formula number field called IsSyncing__c on the on the target detail object that sets its value based on the field you created in the previous step. For instance, IF( c2g__Invoice__r.IsSyncing__c , 1, 0).
8 We recommend that you create a literal mapping in the header ClickLink rule that maps the value True to the IsSyncing__c field on the target header object. This will automatically synchronize target records with source record when they are created.
9 In the Synchronization Setup section of the header ClickLink rule:  
  • Select Sync Enabled, see Sync Enabled for more information. If the synchronization rule is a master rule with no detail rules, select Sync Is Master, see Sync Is Master for more information.
  • Enter IsSyncing__c in the Target Object Sync Active Field.
  • In the Target Object Sync Control Field enter the API name of the field in the target object that you want to use to control when synchronization occurs. See Target Object Sync Control Field.
  • In the Target Object Sync Control When field, enter the values that the Target Object Sync Control Field can be set to on the target record for synchronization between the source header and target header objects to occur. See Target Object Sync Control When.
10 In the Synchronization Setup section of the detail ClickLink rule:  
  • Select Sync Enabled, see Sync Enabled for more information. If the synchronization rule is a master rule with no detail rules, select Sync Is Master, see Sync Is Master for more information.
  • Enter IsSyncing__c in the Target Object Sync Active Field.
  • In the Target Object Sync Control Field enter the API name of the field in the target object that you want to use to control when synchronization occurs. See Target Object Sync Control Field.
  • In the Target Object Sync Control When field, enter the values that the Target Object Sync Control Field can be set to on the target record for synchronization between the source detail and target detail objects to occur. See Target Object Sync Control When.
11 In the header ClickLink rule, select the Source Sync checkbox in each mapping that is to be synchronized.
Note:

Ensure that the Source Sync checkbox is selected on the mapping from the source ID field to the target object.

12 In the detail ClickLink rule, select the Source Sync checkbox in each mapping that is to be synchronized.
Note:

Ensure that the Source Sync checkbox is selected on the mapping from the source ID field to the target object.

13 Create the following Apex trigger in the source header, source detail, target header and target detail objects:
trigger NameofObjectSyncTrigger on APINameofObject (after delete, after insert, after undelete, after update, before delete, before insert, before update) { ffirule.IntegrationRuleEngine.triggerHandler(); }
14 Create a target record from a source record using the ClickLink button.
If you did not create a literal mapping as recommended in step 8, on the target record that you created in the previous step, select IsSyncing.
Note:

When source and target records are synchronized, you cannot edit fields on the target object that are being synchronized with the source object.

Testing Synchronization

Once you have synchronized the records in your source and target objects, we recommend that you carry out these tests to ensure that synchronization is working in the way you expect. If synchronization is not working, ensure that you have correctly carried out the steps in the checklist. See Checklist.

To test synchronization between source and target records:

  1. Create a target record using the button on your source record that runs your ClickLink rule.
  2. If you did not create a literal mapping as recommended in step 8 in the checklist above, in the target record that you created in the previous step, select IsSyncing.
  3. In each target line item, check that the value of the Is Syncing field is 1.00.
  4. Edit the related list of the source object so that you can view the target object records to which it relates.
  5. Edit a field on the source record that is synchronized with a target record.
  6. Click Save.
  7. Check that the value you changed has also changed on the target record.