Salesforce OMS Setup and Customization Guide | MuleSoft Documentation
# Salesforce OMS Setup and Customization Guide
This guide describes how to configure Salesforce OMS for the B2B EDI Order Lifecycle Automation use case.
## Configure Salesforce OMS
Follow the instructions in the Salesforce Order Management Implementation Guide for B2B and D2C Commerce to configure Salesforce OMS. As part of the configuration:
  * Disable the **Enable Reduction Orders** option in **Order Settings**.
  * Enable **Order Management** , **Use Person Accounts** , and **High Scale Orders**
  * Activate **Multiple Currencies**
  * Enable **State** and **Country/Territory** picklists
  * Configure Payment Gateway
  * Configure either a digital wallet or credit card payment method and associate an account with it


## Customize Salesforce OMS
Install the Salesforce package from the Accelerator B2B Common Resources project and verify that the configuration is correct in your Salesforce organization.
Follow these steps in Salesforce OMS after installing the package successfully:
  1. Create a matching rule named `Account Interchange Code Match` in **Setup > Matching Rules**. Enter `Account: B2B_EDISenderCode EXACT MatchBlank = FALSE` in the **Matching Criteria** field.
  2. Create a duplicate rule named `Account Interchange Code Rule` in **Setup > Duplicate Rules**. Select `Account Interchange Code Match` as the matching rule. After you save and activate the duplicate rule, open the rule in **Duplicate Management > Duplicate Rules** and set the order to 1 in the **Reorder** field, which gives the rule precedence over the standard **Account** object matching rule.


### Custom Fields
Verify that the following fields have been created in the corresponding objects:
**Salesforce Object** | **Field Label** | **Field Name** | **Data Type** | **ExternalId**  
---|---|---|---|---  
B2B EDI Sender Code | B2B_EDISenderCode__c | Text(Case Sensitive)  
B2B Order Currency | B2B_OrderCurrency__c  
B2B Order Delivery Method | B2B_OrderDeliveryMethod__c | Lookup(Order Delivery Method)  
B2B Order Sales Channel | B2B_OrderSalesChannel__c | Lookup(Sales Channel)  
B2B Order Store | B2B_OrderStore__c | Lookup(Store)  
Shipment | ExternalId | ExternalId__c  
You must add the **Read** and **Write** permissions to the custom fields created by the Salesforce package.   
---  
### Verify the Custom Object Tab
Verify that your Salesforce org shows the **Pending Order Summary Errors** custom tab.
**Salesforce Object** | **Field Label** | **Field Name** | **Data Type** | **ExternalId**  
---|---|---|---|---  
Pending Order Summary Error | Error Code | Error_Code__c  
Pending Order Summary Error | Error Message | Error_Message__c | Long Text Area  
Pending Order Summary Error | Event Uuid | Event_Uuid__c  
Pending Order Summary Error | External Reference Identifier | External_Reference_Identifier__c  
Pending Order Summary Error | Pending Order Summary Error Name  
### Platform Event
Verify that the `ShipmentCreated` platform event is configured exactly as shown in the following table:
Name | API Name | Event Type | Publish Behavior  
---|---|---|---  
ShipmentCreated | ShipmentCreated__e | High Volume | Publish After Commit  
In addition, verify that the following fields have been created in the `ShipmentCreated` object:
**Field Label** | **Field Name** | **Data Type** | **ExternalId**  
---|---|---|---  
OrderSummaryId | OrderSummaryId__c  
ShipmentId | ShipmentId__c  
### Flows
After installing the Salesforce package, verify that the following flows are available and activated. Customize the flows based on your business requirements.
  * `OMS_Create_OrderSummaryRoutingSchedule_on_OrderSummary_event` - Creates an Order Summary Routing schedule when OMS Order Summary record is created.
  * `OMS_Create_Fulfillment_Orders_on_OrderSummaryRoutingSchedule` - Creates a fulfillment orders after an `Order Summary Routing` schedule record is created.
  * `OMS_Create_Fulfillment_Orders_from_Order_Summary_Subflow` - Used in `OMS_Create_Fulfillment_Orders_on_OrderSummaryRoutingSchedule` flow to create fulfillment orders for an order summary.
  * `OMS_Raise_ShipmentCreated_Event` flow - Creates a platform event when a shipment is created in Salesforce OMS.
  * `OMS_Create_Invoice` - Creates an invoice after the fulfillment order is filled.
  * `OMS_Log_Pending_Order_Summary_Error` - Creates an error record in the `Pending Order Summary Error` object when an error occurs during processing of the `Pending Order Summary Processed Event`.


### Configure Payment Gateway
If you don’t use Salesforce Payments, configure a payment gateway manually to view and manage payments in Order Management. Configure a gateway for each payment provider, including Stripe, PayPal, Adyen, and Cybersource. You can find payment packages on AppExchange for some vendors.
Follow these steps to configure a payment gateway manually:
  1. Follow the Core Payments Reference Gateway Integration Adapters instructions to create a payment gateway adapter class that uses the Salesforce APEX connector framework.
  2. Create a payment gateway provider record that points to your newly created payment gateway adapter class.
  3. Go to **Setup** and define a named credential that contains the gateway provider’s authentication and login information. The adapter class callout definition calls the named credential.
  4. Create a payment gateway record to link the payment gateway provider record and the named credential.


## Error Handling in Salesforce OMS
The Salesforce High Scale Orders API initially records data for order summaries as `PendingOrderSummary`. To troubleshoot errors that occur during the transition from `PendingOrderSummary` to `Order Summary`, use the `OMS_Log_Pending_Order_Summary_Error.flow` process, which subscribes to the `PendingOrderSumProcEvent` event and logs errors in the `Pending Order Summary Error` object. The **Pending Order Summary Errors** custom tab in Salesforce OMS shows the errors.
## Configure Your Connected App for Authentication
Follow these steps to generate the **Consumer Key** and **Consumer Secret** values required for Salesforce authentication:
  1. In your Salesforce org, navigate to **New Connected App** in the **App Manager**.
  2. Enter "MuleSoft Accelerator" as the connected app name and API name.
  3. Enter your email address.
  4. Check the **Enable OAuth Settings**.
  5. Set the callback URL http://localhost.
  6. Select "Full access (full)" in the **Selected OAuth Scopes** list.
  7. Click **Save** , and then click **Continue**.
  8. Click **Manage** to view the connected app details.
  9. Click **Edit Policies**.
  10. Select **All users may self-authorize** in the **OAuth Policies** section.
  11. Select **Relax IP** restrictions in the **IP Relaxation** field.
  12. Click **Save**.
  13. Go to **Setup** and navigate to **App Manager**.
  14. Select **View** from the actions for your connected app.
  15. Click **Manage Consumer Details** in the **API (Enable OAuth Settings)** section.
  16. Verify your identity by entering the verification code from your email.
  17. Copy the values in the **Consumer Key** and **Consumer Secret** fields.
  18. Add the values as the `sfdc.client-id` and `sfdc.client-secret` properties respectively in your Maven settings.xml file.


Use the sample settings.xml file in the Accelerator B2B Common Resources project as a starting point for configuring your connected app.
## Generate a Security Token for Your Service Account
To connect to the Salesforce OMS Cloud instance, you must generate a token for the service account used by Mule applications.
  1. Log in to Salesforce as the service account user, which is the account Mule applications use to connect to Salesforce.
  2. Click the Username icon and select **Settings**.
  3. Select **Reset My Security Token** in **My Personal Information**.
  4. Click **Reset Security Token**.


Salesfoce emails the new security token to the service account user’s address.
The option to reset your security token does not show if you have one or more login IP ranges. To enable the option, remove the login IP ranges from the settings page of the profile assigned to the service account user. Reset your security token, and then restore the login IP ranges.   
---  
## See Also
  *   * MuleSoft Accelerator for Salesforce OMS