You can use this API to create proposal documents for the given format, template name, document type, protection level, and an indicator of whether the document is a draft or final document. As a callback action, the API creates a task for further action.


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

Request Parameter
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

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
documentIDIDThe ID of the generated document.

Code Sample

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

 * The below method demonstrates how to create draft or final proposal document 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 createDocumentForQuote(String ProposalID, String templateName, String protectionLevel, String docFormat, Boolean isDraft){
    Id documentId;
    Id proposalSOId = [SELECT ID FROM Apttus_Proposal__Proposal__c WHERE Name = :ProposalID LIMIT 1].Id;
    Id templateSOId = [SELECT Id, Name FROM Apttus__APTS_Template__cWHERE 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();

        	serverUrl = URL.getSalesforceBaseUrl().toExternalForm() 
                	  + '/services/Soap/u/50.0/' + UserInfo.getOrganizationId();    
		documentId = Apttus_Proposal.MergeWebService.generateDoc2(templateSOId,
    return documentId;