With this API, you can submit an approval request with attachments and comments. This API accepts the object type and object ID of the context object, the process ID, list of attachment IDs, and comments as input parameters. 


APISignature
submitForApprovalsWithAttachmentsAndComments

static Boolean submitForApprovalsWithAttachmentsAndComments(String sObjectType, Id sObjectId, Id processId, List attachmentIds, Apttus_Approval.SubmissionComments submissionComments)

Request Parameters
NameTypeRequired?Description

sObjectId

IDYesID of the approval context object.

sObjectType

StringYesType of the approval context object.
processIdIDYesID of the approval process
attachmentIdsListYesList of attachment IDs
submissionCommentsObjectYesSubmission comments to include in the approval request.
Response Parameter
NameTypeDescription
resultBooleanReturns true if the API is executed successfully.


Code Sample 

// create list of attachments

ID agmtId = 'a013l00000vbQaPAAU';
ID processId = 'a0v3l00000Lp9S1AAJ';
List<ID> contentDocIds = new List<ID>{'0693l00000HookC','0693l00000Hoojn','0693l00000Hooji'};
List<ContentVersion> contentVersions = [SELECT Id, VersionNumber, Title, PathOnClient                                
                                        FROM ContentVersion
                                        WHERE ContentDocumentId IN :contentDocIds];
List<ID> contentVersIds = new List<ID>();
for (ContentVersion contentVersSO : contentVersions) {
    contentVersIds.add(contentVersSO.Id);
}

// create process level submission comments 
SubmissionComments comments = new SubmissionComments();
comments.commentsLevel = SubmissionComments.PROCESS_LEVEL_COMMENTS;
comments.commentsCount = 1;
comments.processName = 'MyProcessName';
comments.processCommentLabel = 'MyProcessLabel';
comments.processCommentMandatory = false;
comments.processComment = 'Here is my submission comment';

// call submit with attachments and comments API
Apttus_Approval.ApprovalsWebService.submitForApprovalsWithAttachmentsAndComments('Apttus_APTS_Agreement_c', agmtId, processId, contentVersIds, comments);

 
CODE