COA_ServiceOrderClone Class

Clone an existing order in the org where the Channel Order App (COA) is installed.

Only fields that you have permission to create are cloned. DML errors can occur if you don’t have sufficient privileges.

Note

Namespace

CHANNEL_ORDERS

Usage

The COA_ServiceOrderClone class contains a single @InvocableMethod to clone orders and, optionally, associated line items. When invoking a method defined in this class, include the CHANNEL_ORDERS namespace prefix:
CHANNEL_ORDERS.class.method(args)

For details about namespace prefixes or the @InvocableMethod annotation, see the Apex Developer Guide.

Example

This example receives a list of service orders, clones them, and returns a list of outputs from the clone operation.

For brevity, the methods invoked in this example omit the CHANNEL_ORDERS namespace prefix. If you use this code in your implementation, you must include the namespace prefix.

Note

public static void cloneOrders(List<Service_Order__c> serviceOrders){
        List<COA_ServiceOrderClone.COA_ServiceOrderCloneInput> serviceOrderCloneInput = new List<COA_ServiceOrderClone.COA_ServiceOrderCloneInput>();

        for(Service_Order__c serviceOrder: serviceOrders){
            COA_ServiceOrderClone.COA_ServiceOrderCloneInput input = new COA_ServiceOrderClone.COA_ServiceOrderCloneInput();
            input.serviceOrderId = serviceOrder.Id;
            input.cloneProducts = true;
            serviceOrderCloneInput.add(input);
        }

        List<COA_ServiceOrderClone.COA_ServiceOrderCloneOutput> serviceOrderCloneOutputs = COA_ServiceOrderClone.clone(serviceOrderCloneInput);
        //Further processing of serviceOrderCloneOutputs
    }