You can use this API to generate documents asynchronously for the given parameters.

APISignature
submitGenerateDoc

webService static Id submitGenerateDoc(Id templateId, Id proposalId, String pLevel, String docFormat, Boolean isDraft, String sessionId, String serverUrl)

Request Parameter
NameTypeRequired?Description
templateIdIDYesThe ID of the template you want to use for the proposal.
proposalIdIDYesThe ID of the proposal for which you want to generate the document.
pLevelStringYesThe protection level you want to apply on the document
docFormatStringYes

The format in which you want to generate the document. The valid values for this parameter are listed below:

  • PDF
  • DOC
  • DOCX
  • RTF
isDraftBooleanYesIndicate whether the generated document is a draft or a final document.
sessionIdStringYesThe session ID you want to use for the callback.
serverUrlStringYesThe server URL you want to use for the callback.
Response Parameter
FieldTypeDescription
asynccallRequestIdIDThe ID of the asynchronous merge call SObject.


Code Sample

The sample code below enables you to create a proposal document asynchronously by providing a valid proposal ID, template name, protection level, format, draft state. After the execution, it returns the ID of the asynchronous merge call SObject.

/**
 * The below method demonstrates how to create draft or final proposal document asynchronously by passing the proposal ID(auto generated ID as record name),
 * template name, protection level, document format and isDraft indicator.
 * Possible protection levels are: 
 *  - Full access,
 *  - Insert comments and tracked changes only, 
 *  - Insert comments only, 
 *  - Fill in form fields only and
 *  - Read only
*/
public Id generateDocAsync (String ProposalID, String templateName, String protectionLevel, String docFormat, Boolean isDraft){
    Id asynccallRequestId;
    Id proposalSOId = [SELECT ID FROM Apttus_Proposal__Proposal__c WHERE Name = :ProposalID LIMIT 1].Id;
    Id templateSOId = [SELECT Id, Name
						FROM Apttus__APTS_Template__c 
						WHERE Name = :templateName AND 
						Apttus__IsActive__c = TRUE 
						LIMIT 1].Id;
    if (proposalSOId != null &&  templateSOId != null) 
	{
        String serverUrl;
        Apttus_Proposal__ProposalSystemProperties__c prop = Apttus_Proposal__ProposalSystemProperties__c.getInstance('System Properties');

        if (prop.Apttus_Proposal__EnableFile__c	) 
		{
			serverUrl = URL.getSalesforceBaseUrl().toExternalForm()
			+ '/services/Soap/u/50.0/' + UserInfo.getOrganizationId();

        } 
		else 
		{
        	serverUrl = URL.getSalesforceBaseUrl().toExternalForm() 
                	  + '/services/Soap/u/50.0/' + UserInfo.getOrganizationId();    
        }
 
       asynccallRequestId = Apttus_Proposal.MergeWebService.submitGenerateDoc(templateSOId,
                                                                        proposalSOId,
                                                                        protectionLevel,
                                                                        docFormat,
                                                                        isDraft,
                                                                        userInfo.getSessionId(),
                                                                        serverUrl);
    }
    return asynccallRequestId;
}
CODE