Difference between revisions of "GenerateDocument"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 13: Line 13:
:;recordID:The identifier of the record to pass to the template.
:;recordID:The identifier of the record to pass to the template.
:;printTemplate:The name or identifier of the [[Document Template]]
:;printTemplate:The name or identifier of the [[Document Template]]
:;format:Specify <tt>CONSTANTS.DOCUMENT.HTML</tt> or <tt>CONSTANTS.DOCUMENT.PDF</tt>
:;format:<tt>CONSTANTS.DOCUMENT.HTML</tt> -or- <tt>CONSTANTS.DOCUMENT.PDF</tt>


'''Return'''
'''Return'''

Revision as of 02:41, 16 January 2014

Generates a document based on an HTML Document Template.

Syntax

Result result;
result = Functions.generateDocument(String object, String recordID, 
                                    String printTemplate, String format);

Parameters

object
The name or identifier of the object that contains the record of interest.
recordID
The identifier of the record to pass to the template.
printTemplate
The name or identifier of the Document Template
format
CONSTANTS.DOCUMENT.HTML -or- CONSTANTS.DOCUMENT.PDF

Return

Result object
Usage
  • Use result.getID() to retrieve the document ID
  • Pass it to the Functions class getDocument() method to get a PlatformFileBean that contains the document
Example
This example calls generateDocument for a lead, creating a HTML document.
String printTemplateID = "";
String leadID = "";
// Some code to populate printTemplateID.
// Some code to populate leadID.
Result result = Functions.generateDocument("LEAD", leadID, printTemplateID, CONSTANTS.DOCUMENT.HTML);
int resultCode = result.getCode();
if(resultCode < 0)
{
    String msg = "Some Message";
    Logger.info(msg + ":\n" + result.getMessage(), "Doc"); // Log details
    Functions.throwError(msg + ".");                       // Error message
}
else
{
    // Some business logic.
}