Partner Order Submit API
Syntax
channel_orders.ServiceOrderProcessor.sendOrder()
channel_orders.ServiceOrderProcessor.sendOrderAsync()
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
It’s 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 one time 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.
//Batch Apex class
global class COABatchClass implements Database.batchable<sObject>, Database.AllowsCallouts, Database.Stateful{
final String DRAFT_STATUS = 'Draft';
global final String query =
'select Id, CHANNEL_ORDERS__Service_Order_Status__c ' +
' from CHANNEL_ORDERS__Service_Order__c where CHANNEL_ORDERS__Service_Order_Status__c =: DRAFT_STATUS';
global Database.QueryLocator start(Database.BatchableContext BC){
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext info, List<CHANNEL_ORDERS__Service_Order__c> scope){
for(CHANNEL_ORDERS__Service_Order__c s : scope){
CHANNEL_ORDERS.ServiceOrderProcessor.sendOrder(s.Id);
}
}
global void finish(Database.BatchableContext BC){}
}
//Batch call
Id batchInstanceId = Database.executeBatch(new COABatchClass(), 1);