Difference between revisions of "GenerateDocument"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 24: Line 24:
:[[Result Class|<tt>Result</tt> object]]
:[[Result Class|<tt>Result</tt> object]]
::* Use <tt>result.getID()</tt> to retrieve the document ID
::* Use <tt>result.getID()</tt> to retrieve the document ID
::* Use [[Functions.getDocumentByID]] method to retrieve the document
::* Use [[Functions.getDocumentByID]] method to retrieve the document<br>?? or [[REST_API:document_Resource]]


;Example:This example calls <tt>generateDocument</tt> for a lead, creating a HTML document.
;Example:This example calls <tt>generateDocument</tt> for a lead, creating a HTML document.

Revision as of 01:20, 16 January 2014

Functions.generateDocument(String objectId, String recordId, String templateId, String format)
Generates document of templateId evaluated with params in the format.
If the format is PDF, it generates the document in PDF format, otherwise HTML format. It relates this generated document to the object of type objectId and record identifier recordId.

Generates a document based on an HTML Document Template.

Syntax

<syntaxhighlight lang="java" enclose="div">

Result result; result = Functions.generateDocument(String objectID, String recordID,

                                   String printTemplateID, String format);

</syntaxhighlight>

Parameters

objectID
The identifier of the related object
recordID
The identifier of the related record
printTemplateID
The name of the Document Template
format
You can specify CONSTANTS.DOCUMENT.HTML or CONSTANTS.DOCUMENT.PDF

Return

Result object
Example
This example calls generateDocument for a lead, creating a HTML document.
<syntaxhighlight lang="java" enclose="div">

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.

} </syntaxhighlight>