FINS AMS Salesforce Sync Handler - Implementation Template

(0 reviews)

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:

  1. 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.
  2. Scheduler for Data Loading into Salesforce FSC:

    • Processes the delta file
    • Utilizes the Bulk API V2 to load the data into Salesforce FSC.
  3. 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

bulb.png 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 ObjectField LabelField NameData TypeLengthUnique*ExternalId
AccountAMS Account IDBKC_AMS_Account_IDText255NY
AccountAMS Writing Carrier IDBKC_AMS_Writing_Carrier_IDText255NY
AccountAMS Billing Company IDBKC_AMS_Billing_Company_IDText255NY
AccountAMS Intermediary IDBKC_AMS_Intermediary_IDText255NY
ProducerAMS Producer IDBKC_AMS_Producer_IDText255NY
InsurancePolicyAMS Policy IDBKC_AMS_Policy_IDText255NY
InsurancePolicyLine of CoverageBKC_Line_of_CoveragePicklist---
InsurancePolicyLimitBKC_LimitCurrency18 - Decimal places 0--
InsurancePolicyCommission PercentageBKC_Commission_PercentagePercentage16 - Decimal places 2--
InsurancePolicyDeductibleBKC_DeductibleCurrency18 - Decimal places 0--
InsurancePolicyEstimated Monthly RevenueBKC_Estimated_Monthly_RevenueFormulaFormula = 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:

  1. Click the Salesforce Setup icon.
  2. Select the Object Manager tab from the Setup home page.
  3. Find and select the target Salesforce object.
  4. Select the Fields & Relationships page.
  5. Click the New button and create the field as specified above.
  6. Once the field has been created, click the Set Field-Level Security button (or do these steps later - see below).
  7. 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.

  1. Click on Salesforce Setup icon and select Developer Console to open a new console window
  2. Go to +File -> New -> Apex class+ and create a new class named CustomFieldUtility
  3. Copy the code from fins-common-resources/salesforce/CustomFieldUtility.apxc to the script editor
  4. Select the +File -> Save+ menu option to compile and save the class
  5. Select +Debug -> Open Execute Anonymous Window+
  6. Copy and paste the contents of fins-ams-sfdc-sync-handler/test/resources/scripts/CreateCustomFields.txt into the window.
  7. 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.

  1. Click the Salesforce Setup icon.
  2. Navigate to +Apps -> App Manager+.
  3. Select New Connected App.
  4. Enter Connected App Name: MuleSoft Accelerator, API Name: MuleSoft_Accelerator and set your email address.
  5. In the API (Enable OAuth Settings) section, check the box Enable OAuth Settings.
  6. Set the callback URL +http://localhost+.
  7. From the Selected OAuth Scopes list, select Full access (full).
  8. Click Save and then Continue.
  9. Click the Manage button to view details for the new connected app.
  10. Click the Edit Policies button.
  11. In the OAuth Policies section, for Permitted Users select All users may self-authorize.
  12. For IP Relaxation, select the Relax IP restrictions option.
  13. 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.

  1. On the Setup Home page, navigate to +Apps -> App Manager+.
  2. Locate your new connected app and choose View from the actions dropdown for that item (last column on the right).
  3. Under the API (Enable OAuth Settings) section, click the Manage Consumer Details button.
  4. Verify your identity by entering the verification code that was emailed to you.
  5. 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.

  1. Log in to Salesforce as the Service Account User (the account that will be used by the Mule applications for connecting to Salesforce).
  2. Click the Username icon in the top right corner and select Settings from the menu.
  3. Select +My Personal Information -> Reset My Security Token+ (if not found, see note below).
  4. Click Reset Security Token.
  5. 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

  1. AMS data file adheres to the format of the provided sample file located in test/resources/sample/ams-data_2201202401.csv.
  2. Handler is configured to process only one file every day.
  3. 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 NameDescription
sftp.hostHostname of the SFTP location
sftp.usernameUsername to connect to the SFTP location
sftp.passwordPassword to connect to the SFTP location
sftp.working-directorySFTP Working directory
sftp.input-directorySFTP Input directory
sftp.success-directorySFTP Success directory
sftp.delta-directorySFTP Delta directory
sftp.archive-directorySFTP Archive directory
sftp.control-directorySFTP Control directory
sftp.failure-directorySFTP Failure directory
sftp.input-file-patternPattern of the input file. The handler will only process input files matching this pattern.
sftp.success-file-nameName of the success file
sftp.delta-file-nameName of the delta file
sftp.control-file-prefixThe prefix used for creating the control files
sftp.control-file-patternPattern of the Control file. The handler will only process control files matching this pattern.
sftp.failed-results-file-prefixThe prefix used for creating the failure results file
sftp.unprocessed-file-prefixThe prefix used for creating the unprocessed results file
sfdc.usernameSalesforce Instance client user Name
sfdc.tokenSalesforce Instance client token
sfdc.passwordSalesforce Instance client password
sfdc.client-idThe Consumer Id of the Connected App in Salesforce
sfdc.client-secretThe Consumer secret of the Connected App in Salesforce
slack-sys.enabledFlag to enable slack notifications
slack-sys.hostHostname of the Slack System API

Additional resources


Reviews

TypeTemplate
OrganizationMuleSoft
Published by
MuleSoft Solutions
Published onJan 30, 2024
Asset overview

Asset versions for 1.0.x

Asset versions
VersionActions
1.0.0