Right click to open menu
Order Management: Data Model and APIs

Menu bar

Quick Actions

Ribbon

Insert:
Error: Internet connection appears to be offline (0)

Outline

Order Management: Data Model and APIsLink to heading
Activity: Review Data Model DocumentationLink to heading
Activity: Object Manager and Schema Builder TourLink to heading
Activity: Order Summary TourLink to heading
Activity: Query an Order Summary with SOQLLink to heading
Activity: Query an Order Summary with REST APILink to heading
Activity: Query an Order Summary with Composite APILink to heading
Activity: Explore Connect REST API BasicsLink to heading
Retrieve Order Product Summary IdLink to heading
Cancel the Order Product SummaryLink to heading

Document

image.png
image.png
Order Management: Data Model and APIs
➡️ This document: https://sfdc.co/OrderManagementAdminGetToKnowDataModelAndAPIs
Horizontal Rule

Activity: Review Data Model Documentation
Last updated by Andrew Francis on 6/23/2022

A thorough understanding of all Order Management objects and their relationships to each other is required to be a successful Order Management Administrator. Please review in full the documentation below
  • Order Management Entity Relationship Diagram
  • Order Management Standard Objects
  • Order Management Objects
Horizontal Rule

Activity: Object Manager and Schema Builder Tour
Last updated by Andrew Francis on 6/23/2022

To understand the relationship of specific objects within the Salesforce Org, we can use the Schema Builder.
  • Navigate to Setup → Object Manager
  • Click Schema Builder at top right
  • image.png
  • Clear Clear All in the left pane to deselect all objects
  • Select the following objects:
  • Order
  • Order Summary
  • Order Product Summary
  • Fulfillment Order
  • Invoice
  • Take note of how the objects are related to each other
  • Add additional objects to understand how other Order Management objects are related
Horizontal Rule

Activity: Order Summary Tour
Last updated by Andrew Francis on 6/23/2022

In this activity, we will dive deeper into the Order Summary that we previously created. Order Summary records provide a single view of all relevant information for an order. Whenever you need information about an order or an action needs to be performed on an order, the Order Summary should be the first place you go.
  • Navigate to the Order Summaries tab
  • Click on the Order Summary we created previously
  • Familiarize yourself with the Summary and Related tabs as well as the Totals card
  • Summary tab includes shipping and payment information
  • Related tab includes all related records like Fulfillment Orders, Invoices, Credit Memos, Process Exceptions, and Return Orders
  • Totals card includes the order totals, shipping cost, and tax

By design Order records are immutable. When an Order is created, an associated Order Summary is created and stamped with the information from the Order record. If any changes need to be made to the order, child records can be created and associated with the Order Summary. The Order Summary will then update any relevant totals or information. 
Horizontal Rule

Activity: Query an Order Summary with SOQL
Last updated by Andrew Francis on 6/23/2022

Like any other Salesforce record, we can retrieve information about an Order Summary using SOQL
  • From anywhere within your Salesforce org, click the gear icon at top right
  • Click Developer Console in the drop down
  • image.png
  • At the bottom of the Developer Console, click the Query Editor tab
  • image.png
  • Enter the following SOQL query 
  • SELECT Id FROM OrderSummary
  • Click Execute
  • Copy the Id for the returned Order Summary, we will need it in the next activity
Horizontal Rule

Activity: Query an Order Summary with REST API
Last updated by Andrew Francis on 6/23/2022

If we know the Id of the Order Summary then we can query the org for additional information using the REST API
  • Navigate to Workbench
  • Login using your org’s credentials
  • Navigate to Utilities → REST Explorer
  • image.png
  • Setup the API Call, ensure you replace your Order Summary Id in the URL
  • Method: GET
  • URL: /services/data/v53.0/sobjects/OrderSummary/Enter_Order_Summary_Id
  • Click Execute
  • image.png
Notice that we are able to retrieve all the fields on the Order Summary object using the REST API. 
Horizontal Rule

Activity: Query an Order Summary with Composite API
Last updated by Andrew Francis on 6/23/2022

We have seen how to retrieve the fields of an Order Summary using the standard REST API. But what if we want to retrieve child records of the Order Summary as well? Using the Composite API, we will retrieve records of multiple object related to the Order Summary with a single API call.
  • Navigate to Workbench
  • Login using your org’s credentials
  • Navigate to Utilities → REST Explorer
  • image.png
  • Setup the API Call, ensure you replace your Order Summary Id in the URL
  • Method: POST
  • URL: /services/data/v53.0/composite
  • Request Body: [Paste the contents from below. Replace the highlighted Order_Summary_Id with the Id retrieved in the previous activity]
  • {
        "compositeRequest":[
            {
                "method":"GET",
                "url":"/services/data/v53.0/query/?q=SELECT+Id,OrderNumber,OrderedDate,Status,TotalAmount,TotalTaxAmount+FROM+OrderSummary+WHERE+Id+=+'Order_Summary_Id'",
                "referenceId":"refOrderSummary"
            },
            {
                "method":"GET",
                "url":"/services/data/v53.0/query/?q=SELECT+Id,TotalAmount,TotalTaxAmount,IsGift,DeliverToAddress,DeliverToCity,DeliverToCountry,DeliverToName,OrderDeliveryMethodId+FROM+OrderDeliveryGroupSummary+WHERE+OrderSummaryId+=+'@{refOrderSummary.records[0].Id}'",
                "referenceId":"refOrderDeliveryGroupSummaries"
            },
            {
                "method":"GET",
                "url":"/services/data/v53.0/query/?q=SELECT+Id,ProductCode,Description,Type,Quantity,UnitPrice,TotalLineAmount,TotalLineTaxAmount+FROM+OrderItemSummary+WHERE+OrderSummaryId+=+'@{refOrderSummary.records[0].Id}'",
                "referenceId":"refOrderItemSummaries"
            },
            {
                "method":"GET",
                "url":"/services/data/v53.0/query/?q=SELECT+Id,OrderAdjustmentGroupSummaryId,OrderItemSummaryId,Name,Amount,TotalTaxAmount+FROM+OrderItemAdjustmentLineSummary+WHERE+OrderSummaryId+=+'@{refOrderSummary.records[0].Id}'",
                "referenceId":"refOrderItemAdjustmentLineSummaries"
            },
            {
                "method":"GET",
                "url":"/services/data/v53.0/query/?q=SELECT+Id,OrderItemSummaryId,OrderItemAdjustmentLineSummaryId,Name,Amount,Rate+FROM+OrderItemTaxLineItemSummary+WHERE+OrderSummaryId+=+'@{refOrderSummary.records[0].Id}'",
                "referenceId":"refOrderItemTaxLineItemSummaries"
            }
        ]
    }
  • Click Execute
  • image.png
Instead of simply retrieving the fields on the Order Summary record, as we did in the previous activity with the REST API, we have used the Composite API to retrieve the Order Summary record, Order Delivery Group Summaries, Order Item Summaries, Order Item Adjustment Line Summaries, and Order Item Tax Line Item Summaries all with a single API call!
Horizontal Rule

Activity: Explore Connect REST API Basics
Last updated by Andrew Francis on 6/23/2022

In this activity we will put our API calls to more practical use by calling the preview-cancel action which will return changes to totals of the order if we canceled an item.
Retrieve Order Product Summary Id
  • From anywhere within your Salesforce org, click the gear icon at top right
  • Click Developer Console in the drop down
  • image.png
  • At the bottom of the Developer Console, click the Query Editor tab
  • image.png
  • Enter the following SOQL query. Replace the highlighted Order_Summary_Id with the Id retrieved in the previous activity.
  • SELECT Id, Name FROM OrderItemSummary WHERE OrderSummaryId = 'Order_Summary_Id' AND Name != 'Shipping'
  • Click Execute
  • image.png
  • Copy the Id from one of the returned Order Product Summaries that you wish to cancel
Cancel the Order Product Summary
  • Navigate to Workbench
  • Login using your org’s credentials
  • Navigate to Utilities → REST Explorer
  • image.png
  • Navigate to your Order Summary
  • Click the Related Tab
  • Click on the Women’s Torpedo Jacket Order Product Summary
  • image.png
  • Setup the API Call, ensure you replace your Order Summary Id in the URL
  • Method: POST
  • URL: [Paste the contents from below. Replace the highlighted Order_Summary_Id with the Id retrieved in the previous activity]
  • /services/data/v53.0/commerce/order-management/order-summaries/Order_Summary_Id/actions/preview-cancel
  • Request Body: [Paste the contents from below. Replace the highlighted Order_Item_Summary_Id with the Id retrieved earlier in this activity]
  • {
        "changeItems":[
            {
                "orderItemSummaryId":"Order_Item_Summary_Id",
                "quantity":1.0,
                "reason":"Damaged",
                "shippingReductionFlag":true
            }
        ]
    }
  • image.png
  • Click Execute

The API call has returned a preview of the balance changes that would occur if the item was cancelled. You can explore additional actions that can be called here.