Page tree
Skip to end of metadata
Go to start of metadata

Salesforce Integration

This topic describes how to set up Salesforce synchronization in your Agiloft knowledgebase.

To view a video tutorial on Salesforce syncing, click here.
 

Prerequisites

Follow these steps

  1. In your Agiloft knowledgebase, select Setup > Sync > New > External Sync.
  2. On the General tab:
    1. Set External System Type to Salesforce.
    2. Set up Directions and Conflicts according to your system requirements.

    3. Click Next.

  3. On the ESA Settings tab:

    1. For the Salesforce WSDL endpoint, enter https://login.salesforce.com/services/Soap/u/33.0.

      Note: This value will be updated from time to time by Salesforce. See the SOAP API Developer Guide for documentation on generating or obtaining the Web Service WSDL.

    2. Enter your Salesforce account email login.

    3. In the Password field, use the following format: <SALESFORCEPASSWORD+SECURITYTOKEN>. For example, SfP@s5w[]rdSECURITYTOKEN.

    4. Click Next.

  4. On the Mapping tab, map the objects in the Agiloft KB with the external Salesforce system. All Salesforce tables are supported in  Agiloft, including both standard tables and custom tables and their relationships. To map an object:

    1. Locate the  Agiloft table in the list and then select the corresponding Salesforce table from the drop-down menu. 

    2. Click Map to open the Field Mapping wizard.

    3. Select a field to use to identify the timestamp for when the records were modified.

    4. Choose whether to synchronize records based on timestamps, or to simply import or export records.
    5. Choose the operations you want to allow during the sync, from both sides of the sync.
    6. Determine how the record ID is generated during the sync. This can be done by Salesforce or in  Agiloft, in which case you must also specify a prefix and a table column in which to store the generated IDs.
    7. For each external field, select the corresponding  Agiloft field and select the Update check boxes to determine which records are updated. For fields with multiple choice values, complete the dialog box that opens for you to map individual choice fields.
    8. Select the Identifying column for the fields you want to use to match records between the systems. If you want to match records only when all the Identifying fields match, select the "Use strict match for identification" check box; otherwise, the system will try to identify matches by all fields, then narrow it down until it can match by any field.

    9. Click Next.

    10. In the Filters tab you can use saved searches as filters for synchronized fields.

  5. On the Relation Mapping tab, set any linked field relations with mapped fields.

    Fields from key linked sets in the Relation Mapping tab cannot be used in the Mapping tab as these will define primary relationships between the key tables. For example, Phone Number or Email fields in the Company mapping are part of the linked set between Company and Contact, and will make it impossible to set up a relationships between Company and Contact in the Relation Mapping tab.

  6. Click Next, then Finish. This will create an entity set using the sync name, which will allow you to transfer your sync to another KB.

Additional Notes:

  1. It is highly recommended for all tables which have strict links for fields which are going to be synced, to select the 'Allow entries not in source table' option in the Mapping tab of the Linked Fields wizard. 
     
    Otherwise, the sync won't be able to save values from SF which aren't represented in the linked AL source. The same is for the unique attribute. For the Demo KB such modifications are:
    1. Lead table - compound field Company / Location Name should be not unique.
    2. Company  and Person table - Linked Field to Locations should be set Loose, otherwise records with addresses not represented in the Locations table will fail on creation.
  2. It is mandatory to match the required level of linked fields between  Agiloft and Salesforce for the tables you are setting up to sync.

    Example

    In Salesforce the Contract to Account relationship is mandatory, whereas in  Agiloft it is a Contract to Company relationship and not required. In this case we need to set the Company linked field as Required. Navigate to Setup > Contract > Company linked field > Edit > Options Tab > Require the user to choose record(s) to be imported? > Yes > Finish.

  3. You can run the sync manually in a table's Action Bar by selecting Actions > Sync > Run <Salesforce account name>.

Sync automation

You can use a time-based rule to setup an automated sync process.

  1. Navigate to Setup > Sync / Edit the Salesforce configuration > Next > Next > Running tab > Select the 'By Actions (Rules/Workflow)' option > Finish.

  2. Navigate to Setup > Rules > New.
  3. In the Rule wizard, in the...
    1. General tab, enter a name and select a table.
    2. Rule Type tab, select At selected time intervals. 
    3. Condition tab, select Run once per scheduled time interval.
    4. Schedule tab, set Apply Rule = <as necessary>.
    5. Action tab, click the Create Sync Action button.
    6.  In the Sync Action wizard:
      1. Enter an action name.
      2. Select your configuration by performing a lookup for the External System ID control.
      3. Click Finish.
    7. Click Finish.

After that, the sync process will run based on the interval set on the Schedule tab.

The sync will operate for all tables mapped in the sync configuration, regardless of which table contains the rule. If you need to sync some tables separately, you will need to create a separate Salesforce ESA configuration for each table and use them in different sync actions. You should be careful with multiple Salesforce syncs that you do not create conflicts with existing mappings.

Managing Attachments

If you intend to synchronize attached file fields with Salesforce and ensure that changes are automatically reflected in Agiloft, you will need to add some code in the Salesforce developer account to act as a trigger. This will automatically update the last modified field of the parent record whenever the attached file is changed in the Salesforce account, which prevents the user from explicitly editing and saving the record after changing the attachment file. 

The sync will create a new version of the file field whenever a change is made. Therefore, in the File with Versioning field setup, you should set "Enable Versioning" to Yes in the Options tab, or changes from Salesforce to  Agiloft will only reflect the first time after sync. The Salesforce field "Attachment" can be used for the sync setup. 

  1. In the home page of the Salesforce Developer Console, click File > New > Apex Trigger
  2. Add a name - such as AttachmentTrigger - and select sObject = Attachment, and click Submit to save it. 
  3. In the console, enter the following code logic, customizing it to use your set of synchronized tables:

    trigger Attachment_Trigger on Attachment (after insert, before delete, after update) {
        Attachment file;
        String[] tableNames = new String[]{'Account','Asset'}; //Add tables based on your sync mapping.
            
            try {
                if(Trigger.isInsert || Trigger.isUpdate) {
                    file = Trigger.new[0];
                }
                if(Trigger.isDelete) {
                    file = Trigger.old[0];
                }
                System.debug('Attachment file: ' + file);
                Attachment parentDetails = [SELECT ParentId, Parent.Type FROM Attachment Where Id = :file.Id];
                System.debug('Parent Type of attachment file: ' + parentDetails.Parent.Type);
                for(String tableName : tableNames) {
                    if(tableName.equalsIgnoreCase(parentDetails.Parent.Type)) {
                        Sobject parentTable = Database.query('SELECT Id, Description FROM ' + parentDetails.Parent.Type + ' where Id=\''+parentDetails.ParentId+'\'');
                        parentTable.put('Description', parentTable.get('Description'));
                        update parentTable;                  
                    }
                }
            } catch (Exception e) {
                System.debug('Exception in attachment_trigger: ' + e);
            }       
    }
  4. Save the trigger.