Accelerator Salesforce Global Party System API - Implementation Template
home
This API implementation template is a shared 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 implements the Accelerator Global Party System API specification. This is a System API for a Global Data Service to manage parties and party roles. A scaled down version of Global Data has been implemented using Salesforce as the back-end system. This API follows the Cloud Information Model (CIM).
This API has endpoints to search Parties (e.g., Individuals), associate ContactPoints to a Party and associate external IDs of other Systems to a Party. A party can be of type Individual or Organization or Households. The only types of ContactPoints that can be associated at this time are ContactPointEmail, ContactPointAddress and ContactPointPhone there can also only be a single instance of each type.
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 imported into Anypoint Studio, proceed with the Prerequisites section.
Prerequisites
This implementation template has the following dependencies:
- Create custom objects in Salesforce to manage External Identifiers
- Create custom fields
- Generate security token for service account user in Salesforce
- Create Connected App in Salesforce
- Enable Household record type (optional)
Custom objects
The following custom objects must be created in Salesforce:
Salesforce Object Name | Singular Label | Plural Label |
---|---|---|
Managed_External_Id | Managed External Identifier | Managed External Identifiers |
Create custom objects manually
- In your Salesforce org, click Setup and select Setup to open Setup.
- Click the Object Manager tab. If you don’t see it, enter Object Manager in the Quick Find box.
- On the Object Manager Object Manager page, click Create | Custom Object.
- For Label, enter the value in
Singular Label
. - For Plural Label, enter the value in
Plural Label
. - Leave the rest of the values as default and click Save.
Create custom objects via Apex script
An Apex class called CustomObjectUtility
and MetadataService
are used to create custom object programmatically. The source can be found on Accelerator Common Resources and MetadataService respectively. Download the 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 namedCustomObjectUtility
- Copy the code from
accel-common-resources/salesforce/CustomObjectUtility.apxc
to the script editor - Select the
File -> Save
menu option to compile and save the class - Go to
File -> New -> Apex class
and create a new class namedMetadataService
- Copy the code from
https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls
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
/src/test/resources/scripts/CreateCustomObjects.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.
Custom fields
The following fields must be created in the corresponding objects.
Salesforce Object | Field Label | Field Name | Data Type | Length | Unique* | ExternalId |
---|---|---|---|---|---|---|
Account | Global Billing Address ID | Global_BillingAddress_Id | Text | 36 | Y | Y |
Account | Global Customer ID | Global_Customer_Id | Text | 36 | Y | Y |
Account | Global Email Address ID | Global_EmailAddress_Id | Text | 36 | Y | Y |
Account | Global Fax Number ID | Global_FaxNumber_Id | Text | 36 | Y | Y |
Account | Global Mailing Address ID | Global_MailingAddress_Id | Text | 36 | Y | Y |
Account | Global Mobile Number ID | Global_MobileNumber_Id | Text | 36 | Y | Y |
Account | Global Party ID | Global_Party_Id | Text | 36 | Y | Y |
Account | Global Phone Number ID | Global_PhoneNumber_Id | Text | 36 | Y | Y |
Account | Global Shipping Address ID | Global_ShippingAddress_Id | Text | 36 | Y | Y |
Account | Customer Status | Customer_Status | Picklist | - | N | N |
Managed_External_Id__c | External Id | External_Id | Text | 80 | N | N |
Managed_External_Id__c | External Id Type | External_Id_Type | Picklist | - | N | N |
Managed_External_Id__c | Object Id | Object_Id | Text | 80 | N | N |
Managed_External_Id__c | Object Type | Object_Type | Picklist | - | N | N |
Managed_External_Id__c | Status | Status | Picklist | - | N | N |
Managed_External_Id__c | Status Last Changed | Status_Last_Changed | Date/Time | - | N | N |
*Unique fields should be case-sensitive
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 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: Instead of adjusting permissions for each field as you go, if you are only making them available to one or two profiles 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.
Additional notes
- The Customer Status picklist values are Prospect, Onboarding, Active, Inactive, Closed, Deceased, Delinquent, and Dormant.
- The External Id Type picklist values are SALESFORCE_B2C, SALESFORCE_CORE, PIM, OFBIZ, SAP_4HANA, MDM, SAP_ECC, SALESFORCE_MARKETING, ORACLE_EBS, POS, SALESFORCE_DC, and SALESFORCE_LM.
- The Object Type picklist values are BillingAddress, Customer, Email, Fax, Household, Individual, MailingAddress, MobilePhone, Organization, Phone, Product, SalesOrder, and ShippingAddress.
- The Status picklist values are VALID, INVALID.
- All
Global_*_Id__c
fields should be visible in layouts (as described above) but made read-only to avoid issues with data synchronization.
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 Accelerator 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
accel-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
/src/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
Identity -> Oauth and OpenID Connect Settings
. - Under 'OAuth and OpenID Connect Flows', ensure 'Allow OAuth Username-Password Flows' is set to 'On'.
- 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.fsc.client-id
and sfdc.fsc.client-secret
properties found in the Clouhub-RCG-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 Accelerator 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.
- Login 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.
Household record type
The following record type must be enabled if CIM Customer with Party as Household
needs to be supported, otherwise this step can be ignored.
Salesforce Object | Record Type |
---|---|
Account | Household |
Household
To enable the Household
record type in Account
object, follow the below steps:
- Click the Salesforce Setup icon.
- Navigate to
+Users -> Profiles+
. - Select the target profile for the service account user.
- Navigate to
+Object Settings -> Accounts+
and click the Edit button. - Under
Record Types and Page Layout Assignments
check theHousehold
record type. - Click the Save button.
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-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 |
---|---|
api.autodiscoveryID | Required if using API Manager to secure this API |
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 |
Testing
Use Advanced Rest Client or Postman to send a request over HTTPS. The template includes a Postman collection in the src/test/resources
folder. Update the collection variable(s) after successful import.
Contact Point Mappings
The following table lists the conditions used to assign ContactPoints in Salesforce:
CIM PartyRoleType - PartyType | Salesforce Object - Record Type | Condition | Action in Salesforce | Comments |
---|---|---|---|---|
Customer - Individual | Account - PersonAccounts | ContactPointAddress with isUsedForBilling set as false and isUsedForShipping set as false | Assign Address as PersonMailingAddress | If multiple addresses match this condition, the one with primaryFlag set to true is used; if none set the first one will be used |
Customer - Individual | Account - PersonAccounts | ContactPointAddress with isUsedForBilling set as true | Assign Address as BillingAddress | |
Customer - Individual | Account - PersonAccounts | ContactPointAddress with isUsedForShipping set as true | Assign Address as ShippingAddress | |
Customer - Individual | Account - PersonAccounts | ContactPointPhone with isSMSCapable set as false | Assign Phone Number as Phone | If multiple phones match this condition, the one with primaryFlag set to true is used; if none set the first one will be used. |
Customer - Individual | Account - PersonAccounts | ContactPointPhone with isSMSCapable set as true | Assign Phone Number as PersonMobilePhone | |
Customer - Organization | Account - Account | ContactPointAddress with isUsedForBilling set as true | Assign Address as BillingAddress | If multiple addresses match this condition, the one with primaryFlag set to true is used; if none set the first one will be used |
Customer - Organization | Account - Account | ContactPointAddress with isUsedForBilling set as true | Assign Address as BillingAddress | If multiple addresses match this condition, the one with primaryFlag set to true is used; if none set the first one will be used |
Customer - Organization | Account - Account | ContactPointAddress with isUsedFoShipping set as true | Assign Address as ShippingAddress | |
Customer - Organization | Account - Account | ContactPointPhone with isFaxCapable set as false | Assign Phone Number as Phone | If multiple phones match this condition, the one with primaryFlag set to true is used; if none set the first one will be used |
Customer - Organization | Account - Account | ContactPointPhone with isFaxCapable set as true | Assign Phone Number as Fax |
*The default value for all flags is false
.
Additional resources
- The Data mappings tab describes how the request and response data structures are mapped between the API interface and the backend Amazon S3 API.
- Refer to the Accelerators documentation home for more information about the MuleSoft Accelerators.