Accelerator Salesforce Global Product System API

(0 reviews)

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 Product System API specification. This is a System API for a Global Data Service to manage products.

This can be used to create, retrieve, update the products along with externalId information into Salesforce.

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 imported into Anypoint Studio, proceed with the Prerequisites section.

Prerequisites

This implementation template has the following dependencies:

  • Create custom objects
  • Create custom fields
  • Generate security token for service account user in Salesforce
  • Create Connected App in Salesforce

Custom objects

The following objects must be created in Salesforce:

Object NameLabelField Name
External_Id_Product_Join__cExternal ID Product JoinExternal ID Product Join
External_Id__cExternal IDExternal IDs
External_Id_Type__cExternal ID TypeExternal ID Types

Custom fields

The following fields must be created in the corresponding objects.

Salesforce ObjectField LabelField NameData TypeLengthUnique*ExternalId
External_Id_Product_Join__cDescriptionDescription__cText80NN
External_Id_Product_Join__cProduct IdProduct_Id__cText80NN
External_Id__cDescriptionDescription__cText80NN
External_Id__cExternal IdExternal_Id__cText80NN
External_Id__cStatusStatus__cPicklist---
External_Id__cExternal Id TypeExternal_Id_Type__cLookup-NN
External_Id_Type__cExternal Id TypeExternal_Id_Type__cText80NN
ProductProduct GroupProduct_Catalog__cPicklist-NN
ProductItem Long DescriptionItem_Long_Description__cText Area-NN
ProductShort DescriptionShort_Description__cText255NN
ProductItem Short DescriptionItem_Short_Description__cText255NN
ProductStatusStatus__cPicklist-NN
ProductGlobal Product IdGlobal_Product_Id__cText80YY

*Unique fields should be case-sensitive

Create via Apex script

An Apex class called CustomObjectUtility and CustomFieldUtility can be used to create custom fields and objects programmatically. The source for this class can be found in the Common Resources project. Download this project and follow the steps below.

Note: "CustomObjectUtility" requires "MetadataService" which can be found on https://github.com/financialforcedev/apex-mdapi/blob/master/apex-mdapi/src/classes/MetadataService.cls.

  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 and CustomFieldUtility
  3. Copy the code from accelerator-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 accelerator-common-resources/salesforce/CreateCustomProductObjects.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.

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 Status picklist values are VALID, INVALID.
    • The Product Group picklist values are Basic, Premium.
  • All Global_*_Id__c fields should be visible in layouts (as described above) but made read-only to avoid issues with data synchronization.

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 Identity -> Oauth and OpenID Connect Settings.
  3. Under 'OAuth and OpenID Connect Flows', ensure 'Allow OAuth Username-Password Flows' is set to 'On'.
  4. Navigate to Apps -> App Manager.
  5. Select New Connected App.
  6. Enter Connected App Name: MuleSoft Accelerator, API Name: MuleSoft_Accelerator and set your email address.
  7. In the API (Enable OAuth Settings) section, check the box Enable OAuth Settings.
  8. Set the callback URL http://localhost.
  9. From the Selected OAuth Scopes list, select Full access (full).
  10. Click Save and then Continue.
  11. Click the Manage button to view details for the new connected app.
  12. Click the Edit Policies button.
  13. In the OAuth Policies section, for Permitted Users select All users may self-authorize.
  14. For IP Relaxation, select the Relax IP restrictions option.
  15. 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 Industry profiles 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 Common Resources project** for a sample settings.xml file that can be used as a starting point.

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

Insert ExternalId Type Records via Apex Script
  1. Click on Salesforce Setup icon and select Developer Console to open a new console window
  2. Select Debug -> Open Execute Anonymous Window
  3. Copy and paste the contents of /src/test/resources/scripts/InsertExternalIDTypeRecords.txt into the window.
  4. Enable the Open Log option and click the Execute 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 NameDescription
api.autodiscoveryIDRequired if using API Manager to secure this API
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

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.

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.

Reviews

TypeTemplate
OrganizationMuleSoft
Published by
MuleSoft Solutions
Published onFeb 27, 2025
Asset overview

Asset versions for 1.1.x

Asset versions
VersionActions
1.1.0