Difference between revisions of "GenerateDocument"

From LongJump Support Wiki
imported>Aeric
imported>Aeric
 
(4 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:generateDocument}}
{{DISPLAYTITLE:generateDocument}}
:<tt>Functions.generateDocument(String objectId, String recordId, String templateId, String format)</tt>
<tt>Functions.generateDocument(String objectId, String recordId, String templateId, String format)</tt>


:Generates document of <tt>templateId</tt> evaluated with <tt>params</tt> in the format.  
:Generates document of <tt>templateId</tt> evaluated with <tt>params</tt> in the format.  
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 a [[Print Templates|Print Template]].
Generates a document based on an [[Print_Templates#Edit_a_Print_Template_based_on_a_Local_HTML_Page|HTML Print Template]].
 
;Considerations:
:[[Print_Templates#Edit_a_Print_Template_based_on_a_Platform_JSP/HTML_Page|JSP Print Templates]] cannot be used, currently.


'''Syntax'''
'''Syntax'''
:<syntaxhighlight lang="java" enclose="div">
Result result;
result = Functions.generateDocument(String objectID, String recordID,
                                    String printTemplateID, String format);
</syntaxhighlight>


<pre>Result result = Functions.generateDocument(String objectID, String recordID, String printTemplateID, String format)</pre>


'''Parameters'''
'''Parameters'''
Line 16: Line 23:
:;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 [[Print Templates|print template]]
:;format:You can specify <tt>CONSTANTS.DOCUMENT.FORMAT.HTML</tt> or <tt>CONSTANTS.DOCUMENT.FORMAT.PDF</tt>
:;format:You can specify <tt>CONSTANTS.DOCUMENT.HTML</tt> or <tt>CONSTANTS.DOCUMENT.PDF</tt>
::This option applies to HTML and PDF templates. Word templates always produce Word files. PowerPoint templates produce PowerPoint files.


'''Return'''
'''Return'''
Line 24: Line 32:
;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.


:{| border="0" cellpadding="5" cellspacing="0"
:<syntaxhighlight lang="java" enclose="div">
|
<syntaxhighlight lang="java" enclose="div">
String printTemplateID = "";
String printTemplateID = "";
String leadID = "";
String leadID = "";
// Some code to populate printTemplateID.
// Some code to populate printTemplateID.
// Some code to populate leadID.
// Some code to populate leadID.
Result result = Functions.generateDocument("LEAD", leadID, printTemplateID, CONSTANTS.FILE.FORMAT.HTML);
Result result = Functions.generateDocument("LEAD", leadID, printTemplateID, CONSTANTS.DOCUMENT.HTML);
int resultCode = result.getCode();
int resultCode = result.getCode();
if(resultCode < 0)
if(resultCode < 0)
Line 44: Line 50:
}
}
</syntaxhighlight>
</syntaxhighlight>
|}
<noinclude>


<noinclude>[[Category:Email and Document Management]]</noinclude>
[[Category:Email and Document Management]]
</noinclude>

Latest revision as of 22:48, 26 June 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 Print Template.

Considerations
JSP Print 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
This option applies to HTML and PDF templates. Word templates always produce Word files. PowerPoint templates produce PowerPoint files.

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.
}