Download page Submitting for Approvals with Attachments and Comments.
Submitting for Approvals with Attachments and Comments
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.
API
Signature
submitForApprovalsWithAttachmentsAndComments
static Boolean submitForApprovalsWithAttachmentsAndComments(String sObjectType, Id sObjectId, Id processId, List attachmentIds, Apttus_Approval.SubmissionComments submissionComments)
Request Parameters
Name
Type
Required?
Description
sObjectId
ID
Yes
ID of the approval context object.
sObjectType
String
Yes
Type of the approval context object.
processId
ID
Yes
ID of the approval process
attachmentIds
List
Yes
List of attachment IDs
submissionComments
Object
Yes
Submission comments to include in the approval request.
Response Parameter
Name
Type
Description
result
Boolean
Returns 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);