FINS AMS Salesforce Sync Handler - Implementation Template
home
This API implementation template is a component of MuleSoft Accelerators, which accelerate the implementation of essential integration use cases.
The solution includes pre-built APIs, connectors, and integration templates that help unlock business-critical data from external systems and guide you in adopting best practices synthesized from thousands of customer implementations. Use these assets as is or extend them to meet your company’s unique needs.
Overview
This integration template enables the synchronization of Insurance Policy Data from an AMS source to a Salesforce Financial Services Cloud (FSC) Organization. The AMS data is provided in CSV format and resides at a specified SFTP location. This process involves three distinct schedulers:
Scheduler for Delta File Generation:
- Identifies changed records by comparing the daily CSV file with the existing success results file (if available).
- Generates a delta file representing the changes.
Scheduler for Data Loading into Salesforce FSC:
- Processes the delta file
- Utilizes the Bulk API V2 to load the data into Salesforce FSC.
Scheduler for Bulk API V2 Job Status Check:
- Monitors the status of the Bulk API V2 job.
- Generates reports for success and failure and unprocessed results.
Note: The first scheduler kicks off daily at precisely 00:00 AM. The subsequent schedulers follow, with the second one scheduled 30 minutes after the first and the third one another 30 minutes later. This can be adjusted as needed using cron expressions in the configuration files.
Getting started
The Getting Started with MuleSoft Accelerators guide provides general information on getting started with the accelerator components. This includes instructions on setting up your local workstation for configuring and deploying the applications. |
Once your workstation has been set up and the application template has been imported into Anypoint Studio, proceed with the Prerequisites section.
Prerequisites
This implementation template has the following dependencies:
- Access to SFTP location
- Ability to create custom fields
- Ability to generate security token for service account user in Salesforce
- A connected app in Salesforce
Please review the use cases described on the MuleSoft Accelerator for Financial Services solution pages for more information about dependencies on other APIs and services.
Custom Fields
The following fields must be created in the corresponding objects.
Salesforce Object | Field Label | Field Name | Data Type | Length | Unique* | ExternalId |
---|---|---|---|---|---|---|
Account | AMS Account ID | BKC_AMS_Account_ID | Text | 255 | N | Y |
Account | AMS Writing Carrier ID | BKC_AMS_Writing_Carrier_ID | Text | 255 | N | Y |
Account | AMS Billing Company ID | BKC_AMS_Billing_Company_ID | Text | 255 | N | Y |
Account | AMS Intermediary ID | BKC_AMS_Intermediary_ID | Text | 255 | N | Y |
Producer | AMS Producer ID | BKC_AMS_Producer_ID | Text | 255 | N | Y |
InsurancePolicy | AMS Policy ID | BKC_AMS_Policy_ID | Text | 255 | N | Y |
InsurancePolicy | Line of Coverage | BKC_Line_of_Coverage | Picklist | - | - | - |
InsurancePolicy | Limit | BKC_Limit | Currency | 18 - Decimal places 0 | - | - |
InsurancePolicy | Commission Percentage | BKC_Commission_Percentage | Percentage | 16 - Decimal places 2 | - | - |
InsurancePolicy | Deductible | BKC_Deductible | Currency | 18 - Decimal places 0 | - | - |
InsurancePolicy | Estimated Monthly Revenue | BKC_Estimated_Monthly_Revenue | Formula | Formula = PremiumAmount * BKC_Commission_Percentage__c | - | - |
- Note : The Line of Coverage picklist values are Commercial D&O, Commercial Monoline and Commercial Package*.
Create Manually via Salesforce
To create each of these custom fields and enable visibility for them on page layouts:
- Click the Salesforce Setup icon.
- Select the
Object Manager
tab from the Setup home page. - Find and select the target Salesforce object.
- Select the
Fields & Relationships
page. - Click the New button and create the field as specified above.
- Once the field has been created, click the
Set Field-Level Security
button (or do these steps later - see below). - Enable for the desired profile, or tick the checkbox next to
Visible
to enable visibility for the desired profile(s).
Repeat these steps for each custom field in the above list.
TIP: If you are only making the custom fields available to one or two profiles, then it may be more efficient to go to the +Users -> Profiles -> {profile} -> Object Settings+
for each object and adjust the permissions for multiple fields at once instead of adjusting permissions for each field as you go.
Create via Apex Script
An Apex class called CustomFieldUtility
can be used to create custom fields programmatically. The source for this class can be found in the FINS Common Resources project. Download this project and follow the steps below.
- Click on Salesforce Setup icon and select
Developer Console
to open a new console window - Go to
+File -> New -> Apex class+
and create a new class namedCustomFieldUtility
- Copy the code from
fins-common-resources/salesforce/CustomFieldUtility.apxc
to the script editor - Select the
+File -> Save+
menu option to compile and save the class - Select
+Debug -> Open Execute Anonymous Window+
- Copy and paste the contents of
fins-ams-sfdc-sync-handler/test/resources/scripts/CreateCustomFields.txt
into the window. - Enable the
Open Log
option and click the Execute button.
Once the script completes, select the Debug Only
filter option to show just the results of each create request. Verify that all fields have been successfully created.
Configure Connected App for Authentication
Follow the below steps to generate the Consumer Key
and Consumer Secret
values required for Salesforce authentication.
- Click the Salesforce Setup icon.
- Navigate to
+Apps -> App Manager+
. - Select
New Connected App
. - Enter Connected App Name:
MuleSoft Accelerator
, API Name:MuleSoft_Accelerator
and set your email address. - In the
API (Enable OAuth Settings)
section, check the boxEnable OAuth Settings
. - Set the callback URL
+http://localhost+
. - From the
Selected OAuth Scopes
list, selectFull access (full)
. - Click Save and then Continue.
- Click the Manage button to view details for the new connected app.
- Click the Edit Policies button.
- In the
OAuth Policies
section, forPermitted Users
selectAll users may self-authorize
. - For
IP Relaxation
, select theRelax IP restrictions
option. - Click Save.
You now need to copy the Consumer Key
and Consumer Secret
values for use in configuring Mule application deployments. More specifically, these must be supplied as the values for the sfdc.client-id
and sfdc.client-secret
properties found in the Clouhub-FINS-DEV
profile in your Maven settings.xml
file.
- On the Setup Home page, navigate to
+Apps -> App Manager+
. - Locate your new connected app and choose
View
from the actions dropdown for that item (last column on the right). - Under the
API (Enable OAuth Settings)
section, click the Manage Consumer Details button. - Verify your identity by entering the verification code that was emailed to you.
- Copy the key and secret values and update your
settings.xml
file as described above.
Download the FINS Common Resources for a sample settings.xml
file that can be used as a starting point.
Generate Security Token for Service Account
A token needs to be generated for the service account used by the Mule applications in order to connect to the FSC instance.
- Log in to Salesforce as the Service Account User (the account that will be used by the Mule applications for connecting to Salesforce).
- Click the Username icon in the top right corner and select
Settings
from the menu. - Select
+My Personal Information -> Reset My Security Token+
(if not found, see note below). - Click Reset Security Token.
- Check the email inbox for an email from Salesforce with the new security token.
NOTE: If the option to reset your security token is not available, it is likely that one or more Login IP Ranges are in effect. These can be temporarily removed from the settings page of the profile assigned to the service account user.
Assumptions
- AMS data file adheres to the format of the provided sample file located in
test/resources/sample/ams-data_2201202401.csv
. - Handler is configured to process only one file every day.
- Any errors encountered during processing will be communicated through Slack notifications.
Deployment
Each Accelerator implementation template in Exchange includes Bash and Windows scripts for building and deploying the APIs to CloudHub. These scripts depend on repositories, global settings, deployment profiles, and associated properties configured in the Maven settings.xml
file.
For additional details, please refer to the Application Deployment section of the Getting Started Guide.
Preparation
Ensure the Maven profile CloudHub-FINS-DEV
has been properly configured in your settings.xml
file. In particular, make sure the common properties for your environment have been provided (e.g., Anypoint Platform client ID and secret).
Required property overrides
Many templates can also be run from Anypoint Studio without having to customize the Run/Debug profiles. However, some templates make use of hidden deployment properties to protect sensitive information (e.g., passwords and secret keys). These properties must be supplied to the runtime by updating the configuration profile and adding them as VM arguments. At a minimum, the following properties must be customized to reflect the target deployment environment:
Property Name | Description |
---|---|
sftp.host | Hostname of the SFTP location |
sftp.username | Username to connect to the SFTP location |
sftp.password | Password to connect to the SFTP location |
sftp.working-directory | SFTP Working directory |
sftp.input-directory | SFTP Input directory |
sftp.success-directory | SFTP Success directory |
sftp.delta-directory | SFTP Delta directory |
sftp.archive-directory | SFTP Archive directory |
sftp.control-directory | SFTP Control directory |
sftp.failure-directory | SFTP Failure directory |
sftp.input-file-pattern | Pattern of the input file. The handler will only process input files matching this pattern. |
sftp.success-file-name | Name of the success file |
sftp.delta-file-name | Name of the delta file |
sftp.control-file-prefix | The prefix used for creating the control files |
sftp.control-file-pattern | Pattern of the Control file. The handler will only process control files matching this pattern. |
sftp.failed-results-file-prefix | The prefix used for creating the failure results file |
sftp.unprocessed-file-prefix | The prefix used for creating the unprocessed results file |
sfdc.username | Salesforce Instance client user Name |
sfdc.token | Salesforce Instance client token |
sfdc.password | Salesforce Instance client password |
sfdc.client-id | The Consumer Id of the Connected App in Salesforce |
sfdc.client-secret | The Consumer secret of the Connected App in Salesforce |
slack-sys.enabled | Flag to enable slack notifications |
slack-sys.host | Hostname of the Slack System API |
Additional resources
- The Data mappings tab describes how the request and response data structures are mapped between the API interfaces.
- Refer to the Accelerators documentation home page for more information about the MuleSoft Accelerators.