Accelerator Salesforce Global Party System API - Implementation Template

(0 reviews)

Prerequisites

This implementation template has the following dependencies:

  • Create Custom object in Salesforce to manage External Identifiers
  • Create Custom fields
  • Generate security token for service account user in Salesforce
  • Connected App in Salesforce
  • Enable Household Record Types (optional)

Custom Objects

The following objects must be created

Salesforce Object NameSingular LabelPlural Label
Managed_External_IdManaged External IdentifierManaged External Identifiers

Create Custom Objects Manually

  1. In your Salesforce org, click Setup and select Setup to open Setup.
  2. Click the Object Manager tab. If you don’t see it, enter Object Manager in the Quick Find box.
  3. On the Object Manager Object Manager page, click Create | Custom Object.
  4. For Label, enter the value in Singular Label.
  5. For Plural Label, enter the value in Plural Label.
  6. Leave the rest of the values as default and click Save.

Create Custom Object 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.

  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 CustomObjectUtility
  3. Copy the code from accel-common-resources/salesforce/CustomObjectUtility.apxc to the script editor
  4. Select the File -> Save menu option to compile and save the class
  5. Go to File -> New -> Apex class and create a new class named MetadataService
  6. Copy the code from https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls to the script editor
  7. Select the File -> Save menu option to compile and save the class
  8. Select Debug -> Open Execute Anonymous Window
  9. Copy and paste the contents of /src/test/resources/scripts/CreateCustomObjects.txt into the window.
  10. 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 ObjectField LabelField NameData TypeLengthUnique*ExternalId
AccountGlobal Billing Address IDGlobal_BillingAddress_IdText36YY
AccountGlobal Customer IDGlobal_Customer_IdText36YY
AccountGlobal Email Address IDGlobal_EmailAddress_IdText36YY
AccountGlobal Fax Number IDGlobal_FaxNumber_IdText36YY
AccountGlobal Mailing Address IDGlobal_MailingAddress_IdText36YY
AccountGlobal Mobile Number IDGlobal_MobileNumber_IdText36YY
AccountGlobal Party IDGlobal_Party_IdText36YY
AccountGlobal Phone Number IDGlobal_PhoneNumber_IdText36YY
AccountGlobal Shipping Address IDGlobal_ShippingAddress_IdText36YY
AccountCustomer StatusCustomer_StatusPicklist-NN
Managed_External_Id__cExternal IdExternal_IdText80NN
Managed_External_Id__cExternal Id TypeExternal_Id_TypePicklist-NN
Managed_External_Id__cObject IdObject_IdText80NN
Managed_External_Id__cObject TypeObject_TypePicklist-NN
Managed_External_Id__cStatusStatusPicklist-NN
Managed_External_Id__cStatus Last ChangedStatus_Last_ChangedDate/Time-NN

*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:

  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 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.

  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 accel-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 /src/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.fsc.client-id and sfdc.fsc.client-secret properties found in the Clouhub-RCG-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 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.

  1. Login 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.

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 ObjectRecord Type
AccountHousehold

Household

To enable the Household record type in Account object, follow the below steps:

  1. Click the Salesforce Setup icon.
  2. Navigate to +Users -> Profiles+.
  3. Select the target profile for the service account user.
  4. Navigate to +Object Settings -> Accounts+ and click the Edit button.
  5. Under Record Types and Page Layout Assignments check the Household record type.
  6. Click the Save button.

Next steps

The Deployment tab provides instructions on how to properly configure the application for running locally from Studio or deploying to CloudHub.


Reviews

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

Asset versions for 1.3.x

Asset versions
VersionActions
1.3.1
1.3.0