Newer Version Available

This content describes an older version of this product. View Latest

Partner Order Submit API

Send orders to Salesforce immediately or asynchronously using the Partner Order Submit API. The API is available in version 1.39 and earlier of the Channel Order App (COA).

In COA v2.0 and later, the Channel Order Apex API replaces the Partner Order Submit API. We encourage you to migrate integrations with the Partner Order Submit API to the Channel Order Apex API.

Note

Syntax

1channel_orders.ServiceOrderProcessor.sendOrder()
2channel_orders.ServiceOrderProcessor.sendOrderAsync()

When you submit an order using sendOrder or sendOrderAsync, include an order ID or set of order IDs as the argument. For example, channel_orders.ServiceOrderProcessor.sendOrder(orderId).

Note

Usage

Use sendOrderAsync when you want to create or update multiple orders and send them in the same transaction. See the example in this section for more details.

Rules and Guidelines

This is an Apex implementation, so all Apex usage rules and limits apply. Salesforce supports only one order per call.

Use the Partner Submit API to send an order after it has been created using a valid Service Order ID. You can create Service Order and Service Order Detail records using the Channel Order App, data loading, or automated processing.

Each order must include the fields listed on the Service Order and Service Order Detail objects.

Methods

The ServiceOrderProcessor object supports the following methods.

Name Arguments Description
sendOrder ID Submit an order with a single ID immediately.
sendOrder Set of IDs Submit an order with a set of IDs immediately.
sendOrderAsync ID Submit an order with a single ID asynchronously (@future).
sendOrderAsync Set of IDs Submit an order with a set of IDs asynchronously (@future).

Example: Batching on the Partner Order Submit API

You can only invoke ServiceOrderProcessor once per Apex transaction. If you pass a set of IDs to sendOrder or sendOrderAsync, the maximum set size is 5. This example uses a batch job to work around this limitation.

In this example, if you have 100 orders in Draft status, the code creates one batch job with 100 executions, because only one record is processed per execution.
1//Batch Apex class
2global class COABatchClass implements Database.batchable<sObject>, Database.AllowsCallouts, Database.Stateful{
3   final String DRAFT_STATUS = 'Draft';
4   global final String query =
5      'select Id, CHANNEL_ORDERS__Service_Order_Status__c ' +
6      ' from CHANNEL_ORDERS__Service_Order__c where CHANNEL_ORDERS__Service_Order_Status__c =: DRAFT_STATUS';
7
8   global Database.QueryLocator start(Database.BatchableContext BC){
9      return Database.getQueryLocator(query);
10   }
11
12   global void execute(Database.BatchableContext info, List<CHANNEL_ORDERS__Service_Order__c> scope){
13       for(CHANNEL_ORDERS__Service_Order__c s : scope){
14         CHANNEL_ORDERS.ServiceOrderProcessor.sendOrder(s.Id);
15         }
16   }
17   global void finish(Database.BatchableContext BC){}
18}
19
20//Batch call
21Id batchInstanceId = Database.executeBatch(new COABatchClass(), 1);