With this API, you can submit bulk approval requests for review. This API accepts the object type and the object ID of the context object as input parameters. You can also add comments to your approval requests. You cannot submit approval requests with attachments. 

If you submit previously submitted or approved approvals as part of bulk approval request, the approval request is submitted again. 

This API is useful when you need to submit a large number of approval requests for various context objects. For example, you are the approvals admin for a data service organization and you need to submit all the approval records for 5 agreements. Using submiForApprovalsBulk API, you can submit all the approval records in one go by calling this API and providing the type and IDs of the five agreements as request parameters. 

APISignature
submitForApprovalsBulkwebService static Boolean submitForApprovalsBulk(List ctxObjParams)
Request Parameters
NameTypeRequired?Description
ctxObjParamsObjectYesObject containing all the approval parameters
approvalParams
NameTypeRequired?Description

approvalObjectId

IDYesID of the approval context object.

approvalObjectType

StringYesType of the approval context object.
approvalCommentsObjectObjectNoThe approval comment object
Response Parameter
NameTypeDescription
resultBooleanReturns true if the API is executed successfully.
/**
 *  Apttus Approvals Management
 *  BulkCtxObjectParam
 *   
 *  @2020 Apttus Inc. All rights reserved.
 */
global with sharing class BulkCtxObjectParam {
    
    /**
     * Context Object Type
     */
    webservice String ctxSObjectType { global get; global set; }
    
    /**
     * Context Object Id
     */
    webservice ID ctxSObjectId { global get; global set; }
    
    /**
     * Submission Comments
     */
    webservice SubmissionComments comments { global get; global set; }

    /**
     * Global Constructor
     */
    global BulkCtxObjectParam() {
        ctxSObjectType = null;
        ctxSObjectId = null;
        comments = null;
        
    }

	/**
	 * Creates the json representation of the bulk context objects
	 * @return the json string
	 */
	global String toJSON() {
		// get the json representation
		return System.JSON.serializePretty(this);
       	
	}
    
 	/**
	 * Parses the bulk context object param from the given JSON string
	 * @param jsonString the json string to parse
 	 * @return the bulk context param object
	 */
	global static BulkCtxObjectParam parse(String jsonString) {
		// load the class (salesforce class loading bug)
        System.Type wrapperType = System.Type.forName(SystemUtil.getFQClassName('BulkCtxObjectParam')); 
        // deserialize the object
        return (BulkCtxObjectParam) System.Json.deserialize(jsonString, BulkCtxObjectParam.class);
			
	}
	
}
// multiple context object type and ids
String agmtType = 'Apttus__APTS_Agreement__c';
ID agmtId1 = 'a07R000000APxGG';
ID agmtId2 = 'a07R000000AS9nJ';
ID agmtId3 = 'a07R000000AS9nO';

// submission comments
Apttus_Approval.SubmissionComments submitComments1 = new Apttus_Approval.SubmissionComments();
submitComments1.commentsLevel = Apttus_Approval.SubmissionComments.PROCESS_LEVEL_COMMENTS;
submitComments1.commentsCount = 1;
submitComments1.processName = 'ProcessName';
submitComments1.processCommentLabel = 'ProcessLabel';
submitComments1.processCommentMandatory = false;
submitComments1.processComment = 'Test Comment 1';

Apttus_Approval.SubmissionComments submitComments2 = new Apttus_Approval.SubmissionComments();
submitComments2.commentsLevel = Apttus_Approval.SubmissionComments.PROCESS_LEVEL_COMMENTS;
submitComments2.commentsCount = 1;
submitComments2.processName = 'ProcessName';
submitComments2.processCommentLabel = 'ProcessLabel';
submitComments2.processCommentMandatory = false;
submitComments2.processComment = 'Test Comment 2';

Apttus_Approval.SubmissionComments submitComments3 = null;


// create list of context objects
List<Apttus_Approval.BulkCtxObjectParam> ctxParams = new List<Apttus_Approval.BulkCtxObjectParam>();

Apttus_Approval.BulkCtxObjectParam ctxParam1 = new Apttus_Approval.BulkCtxObjectParam();
ctxParam1.ctxSObjectType = agmtType;
ctxParam1.ctxSObjectId = agmtId1;
ctxParam1.comments = submitComments1;
ctxParams.add(ctxParam1);

Apttus_Approval.BulkCtxObjectParam ctxParam2 = new Apttus_Approval.BulkCtxObjectParam();
ctxParam2.ctxSObjectType = agmtType;
ctxParam2.ctxSObjectId = agmtId2;
ctxParam2.comments = submitComments2;
ctxParams.add(ctxParam2);

Apttus_Approval.BulkCtxObjectParam ctxParam3 = new Apttus_Approval.BulkCtxObjectParam();
ctxParam3.ctxSObjectType = agmtType;
ctxParam3.ctxSObjectId = agmtId3;
ctxParam3.comments = submitComments3;
ctxParams.add(ctxParam3);

// bulk submit
Boolean ok = Apttus_Approval.ApprovalsWebService.submitForApprovalsBulk(ctxParams);
CODE

Integration Details

Use the following information in your integrations with Apttus Intelligent Workflow Approvals API. Refer to Integrating Apttus with External Systems for information on how to get started.

API Prerequisites

None.

Response/Request XML

Example Request

<soapenv:Envelope 
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:app="http://soap.sforce.com/schemas/class/Apttus_Approval/ApprovalsWebService" 
xmlns:bul="http://soap.sforce.com/schemas/class/Apttus_Approval/BulkCtxObjectParam" 
xmlns:sub="http://soap.sforce.com/schemas/class/Apttus_Approval/SubmissionComments">
   <soapenv:Header>
      <app:SessionHeader>
         <app:sessionId>00DR0000001nyVR!ARYAQOruA8X3nIS2hgZgZxEZkUDHDMlzIfBNGDey8s_.AcTbbEghNGUnMEh5oGcG5mkmrVuHp1F9gHzfIfYAvzuRDU6zg7kO</app:sessionId>
      </app:SessionHeader>
   </soapenv:Header>
   <soapenv:Body>
      <app:submitForApprovalsBulk>
         <!--Zero or more repetitions:-->
         <app:ctxObjParams>
            <bul:comments>
               <sub:commentsCount>1</sub:commentsCount>
               <sub:commentsLevel>Process</sub:commentsLevel>
               <sub:processComment>?</sub:processComment>
               <sub:processCommentLabel>ProcessLabel</sub:processCommentLabel>
               <sub:processCommentMandatory>false</sub:processCommentMandatory>
               <sub:processName>ProcessName</sub:processName>
               <!--Zero or more repetitions:-->
               <sub:stepCommentList>
               </sub:stepCommentList>
            </bul:comments>
            <bul:ctxSObjectId>a07R000000AiYQX</bul:ctxSObjectId>
            <bul:ctxSObjectType>Apttus__APTS_Agreement__c</bul:ctxSObjectType>
         </app:ctxObjParams>
         <app:ctxObjParams>
            <bul:comments />
            <bul:ctxSObjectId>a07R000000Aj68Y</bul:ctxSObjectId>
            <bul:ctxSObjectType>Apttus__APTS_Agreement__c</bul:ctxSObjectType>
         </app:ctxObjParams>
      </app:submitForApprovalsBulk>
   </soapenv:Body>
</soapenv:Envelope>
XML

Example Response

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://soap.sforce.com/schemas/class/Apttus_Approval/ApprovalsWebService">
   <soapenv:Body>
      <submitForApprovalsBulkResponse>
         <result>true</result>
      </submitForApprovalsBulkResponse>
   </soapenv:Body>
</soapenv:Envelope>
XML