With this API, you can submit an approval request with attachments. Conga Approvals provide the following APIs to submit an Approval Request with Attachments:

submitForApprovalsWithAttachments(String sObjectType, Id sObjectId, Id processId, List attachmentIds)

This API accepts the object type and object ID of the context object, the process ID and the list of attachment IDs as input parameters. 


APISignature
submitForApprovalsWithAttachments

static Boolean submitForApprovalsWithAttachments(String sObjectType, Id sObjectId, Id processId, List attachmentIds)

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
Response Parameter
NameTypeDescription
resultBooleanReturns true if the API is executed successfully.


Code Sample 

/**
 * Submit given approval context with attachments
 * @param sObjectType the approval context sobject type 
 * @param sObjectId the approval context sobject identifier
 * @param processId the id of the approval process 
 * @param attachmentIds list of attachment ids (files or attachments) to include
 * @return <code>true</code> if successful
 */
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);
}
// submit with attachments
Apttus_Approval.ApprovalsWebService.submitForApprovalsWithAttachments('Apttus_APTS_Agreement_c',agmtId,processId,contentVersIds);
CODE

submitForApprovalsWithAttachments(String sObjectType, Id sObjectId, Id processId, Map templateFld2NameIdMap)

This API accepts the object type and the object ID of the context object as input parameters. 


APISignature
submitForApprovalsWithAttachments

static Boolean submitForApprovalsWithAttachments(String sObjectType, Id sObjectId, Id processId, Map templateFld2NameIdMap)

Request Parameters
NameTypeRequired?Description

sObjectId

IDYesID of the approval context object.

sObjectType

StringYesType of the approval context object.
processIdIDYesID of the approval process
templateFld2NameIdMapMapYesMap of process instance template field names and template names
Response Parameter
NameTypeDescription
resultBooleanReturns true if the API is executed successfully.

Using submitForApprovalsWithAttachments API to send Files

You can also use this API to send Files instead of Attachments. Sending Files is a four-step process as follows:

  1. Select the process Id and file Id (or attachment Id)  to submit.

  2. Clone the email templates using the CloneEmailTemplate API. You need to clone the email templates to create temporary templates before you can copy attachments to them.

  3. Copy the files or attachments using the CopyAttachment API. 

  4. Get the developer names of the email templates you want to use. Create a map with the template field names and their respective template developer names and pass this to the submitForApprovalsWithAttachments API in the processProperties parameter.

Code Sample 

// ===================================================================================
//	Step 1 - select process
// ===================================================================================

// agreement id
ID agmtId = 'a013l00000vbQaPAAU';
// content document id
ID contentDocId = '0693l00000HookC';
// get content version
List<ContentVersion> contentVersions = [SELECT Id, VersionNumber, Title, PathOnClient, ContentDocumentId, ContentDocument.Title									    	FROM ContentVersion
					WHERE ContentDocumentId = :contentDocId];
system.debug('contentVersions[0]='+contentVersions[0]);
ID contentVersionId = contentVersions[0].Id;
system.debug('contentVersionId='+contentVersionId);

// select process
ID processId = Apttus_Approval.ApprovalsWebService.selectApprovalProcess('Apttus__APTS_Agreement__c', agmtId);
system.debug('processId='+processId);

// ===================================================================================
//	Step 2 - clone email templates
// ===================================================================================

// get email templates for process
// Apttus My Approvals Notification (Assignment)
ID asTemplateId = '00X1N000000jwAr';
// Apttus My Approvals Notification (Reassignment)
ID reTemplateId = '00X1N000000jwAv';
// Apttus My Approvals Notification (Escalation)
ID esTemplateId = '00X1N000000jwAt';
// Apttus My Approvals Notification (NotifyOnly)
ID noTemplateId = '00X1N000000jwAu';

// clone templates
ID asClonedTemplateId = Apttus_Approval.ApprovalsWebService.cloneEmailTemplate(asTemplateId);
ID reClonedTemplateId = Apttus_Approval.ApprovalsWebService.cloneEmailTemplate(reTemplateId);
ID esClonedTemplateId = Apttus_Approval.ApprovalsWebService.cloneEmailTemplate(esTemplateId);
ID noClonedTemplateId = Apttus_Approval.ApprovalsWebService.cloneEmailTemplate(noTemplateId);
system.debug('asClonedTemplateId='+asClonedTemplateId);
system.debug('reClonedTemplateId='+reClonedTemplateId);
system.debug('esClonedTemplateId='+esClonedTemplateId);
system.debug('noClonedTemplateId='+noClonedTemplateId);

// ===================================================================================
//	Step 3 - copy attachments to cloned email templates
// ===================================================================================

// have to do this in separate execution thread otherwise get error:

ID processId = 'a0v3l00000Lp9S1AAJ';
ID contentVersionId = '0683l00000IlB4xAAF';
ID asClonedTemplateId = '00X3l000001qRAHEA2';
ID reClonedTemplateId = '00X3l000001qRAIEA2';
ID esClonedTemplateId = '00X3l000001qRAJEA2';
ID noClonedTemplateId = '00X3l000001qRAKEA2';

// copy attachments to cloned templates
Boolean copyAs = Apttus_Approval.ApprovalsWebService.copyAttachment(asClonedTemplateId, contentVersionId);
Boolean copyRe = Apttus_Approval.ApprovalsWebService.copyAttachment(reClonedTemplateId, contentVersionId);
Boolean copyEs = Apttus_Approval.ApprovalsWebService.copyAttachment(esClonedTemplateId, contentVersionId);
Boolean copyNo = Apttus_Approval.ApprovalsWebService.copyAttachment(noClonedTemplateId, contentVersionId);

// ===================================================================================
//	Step 4 - submit with attachments
// ===================================================================================

ID agmtId = 'a013l00000vbQaPAAU';
ID processId = 'a0v3l00000Lp9S1AAJ';
ID asClonedTemplateId = '00X3l000001qRAHEA2';
ID reClonedTemplateId = '00X3l000001qRAIEA2';
ID esClonedTemplateId = '00X3l000001qRAJEA2';
ID noClonedTemplateId = '00X3l000001qRAKEA2';

// get cloned template names
List<ID> clonedTemplateIds = new List<ID>();
clonedTemplateIds.add(asClonedTemplateId);
clonedTemplateIds.add(reClonedTemplateId);
clonedTemplateIds.add(esClonedTemplateId);
clonedTemplateIds.add(noClonedTemplateId);

List<EmailTemplate> templates = [SELECT Id, DeveloperName
                                 FROM EmailTemplate
                                 WHERE Id IN :clonedTemplateIds];
system.debug('templates='+templates);

String asClonedTemplateName = 'TEMPpEUFEwzmOwGmG7gMTwMn4MQPd';
String reClonedTemplateName = 'TEMPkBT6h3HbJSvkNn2jN2aYGDv7A';
String esClonedTemplateName = 'TEMPlDvMQ2epmJpk33IhrJUxDkCpG';
String noClonedTemplateName = 'TEMPlMgrRErwNI7ZnJrajTZrdP4Du';

// create process properties map containing cloned template names
Map<String,String> templateFldName2NameMap = new Map<String,String>();
templateFldName2NameMap.put('Apttus_Approval__AssignmentEmailTemplate__c', asClonedTemplateName);
templateFldName2NameMap.put('Apttus_Approval__ReassignmentEmailTemplate__c', reClonedTemplateName);
templateFldName2NameMap.put('Apttus_Approval__EscalationEmailTemplate__c', esClonedTemplateName);
templateFldName2NameMap.put('Apttus_Approval__NotifyOnlyEmailTemplate__c', noClonedTemplateName);
system.debug('templateFldName2NameMap='+templateFldName2NameMap);

// submit with attachments
Apttus_Approval.ApprovalsWebService.submitForApprovalsWithAttachments('Apttus__APTS_Agreement__c', 
                                                      			agmtId, 
                                                      			processId,
                                                      			templateFldName2NameMap);

CODE