You can use this API to create proposal documents for the given format, template name, document type, and protection level. As a callback action, the API creates a task for further action.

APISignature
generateDoc

webService static Id generateDoc(Id templateId, Id proposalId, String pLevel, String docFormat, 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
sessionIdStringYesThe session ID you want to use for the callback.
serverUrlStringYesThe server URL you want to use for the callback.
Response Parameter
FieldTypeDescription
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, and format. After the execution, it returns the proposal document ID.

/**
 * The below method demonstrates how to create proposal document by passing the proposal ID(auto generated ID as record name),
 * template name, protection level and document format.
 * 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)
{
    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__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();    
        }
 
       documentId = Apttus_Proposal.MergeWebService.generateDoc(templateSOId,
																proposalSOId, 
																protectionLevel,
																docFormat,
																userInfo.getSessionId(),
																serverUrl);
    }
    return documentId;
}
CODE