invokeBatchSerially Method

Performs multiple batch operations (one after another) on a set of records.

It executes a number of Integration Procedures-based batch jobs in succession. It also supports the pre and post-processing steps on every batch.

For example, you could use it for various group-level (Quote/Order Group) actions to perform different sequential batch jobs on a set of quotes and orders.

  1. Validate and Price:

    • Validation

    • Pricing (gets fired once the validation batch-job is finished)

  2. Create and Submit Order:

    • Create Order (Quote checkout with price:false)

    • Price Sub-Orders

    • Submit Order (checkout the orders created in the initial batch)

For other uses, see invokeBatchSerially Method.

Class 

Input Parameters 

batchInput expects the list of objects as input. Every individual object represents a single batch job to execute.

ParameterRequiredDescription
batchOperationTypeindicatesRequiredThe name of the batch process.
batchSizeRequiredBatch-size configuration for the batch job to run.
classNameRequiredThe corresponding Apex class to invoke for the batch job. This class should extend MSInvokeVIPInBatch and can override start, execute, and finish methods if required.
classParamsRequiredThe Integration Procedures to execute at different stages of the batch job.
    1<li>`vipName` listed in `startVIP` is executed at the start of the batch.</li>
    2
    3 <li>`executeVIP` is called as part of the execution process.</li>
    4
    5 <li>`finishVIP` runs during the finish process of the batch.</li>
    6
    7 <li>Additional VIP-level inputs can be provided in `vipParams`.</li>
    Also, `classParams` can contain an additional set of class-level inputs.|

    Output Parameters 

    ParameterDescription
    isJobStartedTrue — The batch job has started successfully.

    Example Input Data 

    1"batchInput": [
    2  {
    3    "batchOperationType": "Validate",
    4    "batchSize": 1,
    5    "className": "vlocity_cmt.MSInvokeCartValidationBatch",
    6    "classParams": {
    7      "startVIP": {
    8        "vipName": "",
    9        "vipParams": {}
    10      },
    11      "executeVIP": {
    12        "vipName": "MultiService_RunCartValidation",
    13        "vipParams": {}
    14      },
    15      "finishVIP": {
    16        "vipName": "MultiService_FinishCartValidation",
    17        "vipParams": {}
    18      }
    19    }
    20  },
    21  {
    22    "batchOperationType": "Price",
    23    "batchSize": 1,
    24    "className": "vlocity_cmt.MSInvokeCartPricingBatch",
    25    "classParams": {
    26      "startVIP": {
    27        "vipName": "",
    28        "vipParams": {}
    29      },
    30      "executeVIP": {
    31        "vipName": "MultiService_RunCartPricing",
    32        "vipParams": {}
    33      },
    34      "finishVIP": {
    35        "vipName": "MultiService_FinishCartPricing",
    36        "vipParams": {}
    37      }
    38    }
    39  }
    40]

    Example Output Data 

    1{
    2  "isJobStarted": "false",
    3  "error": "OK",
    4  "errorLabel" : "Batch Job Failed to Start",
    5  "message": "Batch job cannot be started as salesforce limit exceeded. Please contact administrator."
    6}

    Process Different Records 

    This remote action can also support the scenario where the next batch is expected to process a different set of records than the previous one.

    For example, in the Create and Submit Order batch, the finish stage of Create-Order and the whole Price and Submit-Order batches should process the new orders created by the previous batch. This is possible by splitting the finish of the Create-Order process into three steps:

    1. Run beforeCtxSwitchFinishVIP.

    2. Perform context switch.

    3. Run afterCtxSwitchFinishVIP.

    The corresponding batch-object of the input is shown in the following example.

    1{
    2  "batchOperationType": "CreateOrder",
    3  "batchSize": 1,
    4  "className": "vlocity_cmt.MSInvokeCreateOrderBatch",
    5  "classParams": {
    6    "startVIP": {
    7      "vipName": "MultiService_StartCheckoutQuote",
    8      "vipParams": {}
    9    },
    10    "executeVIP": {
    11      "vipName": "MultiService_CheckoutQuote",
    12      "vipParams": {}
    13    },
    14    "beforeCtxSwitchFinishVIP": {
    15      "vipName": "",
    16      "vipParams": {}
    17    },
    18    "afterCtxSwitchFinishVIP": {
    19      "vipName": "MultiService_FinishCheckoutQuote",
    20      "vipParams": {}
    21    }
    22  }
    23}