Difference between revisions of "GenerateDocument"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
m (Text replace - 'Print Template' to 'Document Template')
Line 6: Line 6:
: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 <tt>objectId</tt> and record identifier <tt>recordId</tt>.
: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 <tt>objectId</tt> and record identifier <tt>recordId</tt>.


Generates a document based on an [[Print_Templates#Edit_a_Print_Template_based_on_a_Local_HTML_Page|HTML Print Template]].
Generates a document based on an [[Print_Templates#Edit_a_Print_Template_based_on_a_Local_HTML_Page|HTML Document Template]].


;Considerations:
;Considerations:
:[[Print_Templates#Edit_a_Print_Template_based_on_a_Platform_JSP/HTML_Page|JSP Print Templates]] cannot be used, currently.
:[[Print_Templates#Edit_a_Print_Template_based_on_a_Platform_JSP/HTML_Page|JSP Document Templates]] cannot be used, currently.


'''Syntax'''
'''Syntax'''
Line 22: Line 22:
:;objectID:The identifier of the related object
:;objectID:The identifier of the related object
:;recordID:The identifier of the related record
:;recordID:The identifier of the related record
:;printTemplateID:The name of the [[Print Templates|print template]]
:;printTemplateID:The name of the [[Document Templates|print template]]
:;format:You can specify <tt>CONSTANTS.DOCUMENT.HTML</tt> or <tt>CONSTANTS.DOCUMENT.PDF</tt>
:;format:You can specify <tt>CONSTANTS.DOCUMENT.HTML</tt> or <tt>CONSTANTS.DOCUMENT.PDF</tt>



Revision as of 00:10, 18 December 2012

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.

Considerations
JSP Document Templates cannot be used, currently.

Syntax

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


Parameters

objectID
The identifier of the related object
recordID
The identifier of the related record
printTemplateID
The name of the print 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.
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";
    Functions.debug(msg + ":\n" + result.getMessage());  // Log details
    Functions.throwError(msg + ".");                     // Error dialog
}
else
{
    // Some business logic.
}