Creating an AdvoDoc Document Via Code

The following Apex method can be used create a new document via custom coding. Please be aware this method requires knowledge of Force.com best practices and as always we suggest testing your code in the Sandbox.

Syntax:
DocumentService.storeDocument(
@recordId,
@templateId [,
@outputformat ]
);
 

Parameters:
@recordId
Required. The Id value of the base object's source record for which AdvoDoc should be generated for.

@templateId
Required. The AdvoDoc Template Id to be used for merging with the source record to create the new document.

@outputformat
Optional. The output format is either PDF or DOCX. This is an optional parameter and if not provided, the API function will default to the value provided on the AdvoDoc Template. If the template format is not specified the defaulted format will be PDF.

Result:
The function call will return a JSON formatted string in this format: {success:"",result:""}

success
Will be either TRUE or FALSE

result
A confirmation text of completion OR error text if the process is halted by an unexpected error.

Example:
DocumentService.storeDocument(
   'a0b9000000RJhKTEA1',
   'a0d9000000GTrsgAA4'
);

OR

DocumentService.storeDocument(
   'a0b9000000RJhKTEA1',
   'a0d9000000GTrsgAA4',
   ‘PDF’
);