Difference between revisions of "GenerateDocument"
From AgileApps Support Wiki
imported>Aeric |
imported>Aeric |
||
(3 intermediate revisions by the same user not shown) | |||
Line 6: | Line 6: | ||
Result result; | Result result; | ||
result = Functions.generateDocument(String object, String recordID, | result = Functions.generateDocument(String object, String recordID, | ||
String | String templateID, String format); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 12: | Line 12: | ||
:;object:The name or identifier of the object that contains the record of interest. | :;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. | :;recordID:The identifier of the record to pass to the template. | ||
:;printTemplate:The | :;printTemplate:The identifier of the [[Document Template]]. | ||
::To get the template ID: | |||
:::* Go to '''[[File:GearIcon.png]] > Objects > {object} > Document Templates''' | |||
:::* Click the Wrench icon to edit the view or create a new one | |||
:::* Add the recordID field to the view | |||
:::* In the listing, find the ID of the Document Template you'll be using | |||
:;format:<tt>CONSTANTS.DOCUMENT.HTML</tt> -or- <tt>CONSTANTS.DOCUMENT.PDF</tt> | :;format:<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''' |
Latest revision as of 22:46, 26 June 2014
Generates a document based on an HTML Document Template.
Syntax
Result result; result = Functions.generateDocument(String object, String recordID, String templateID, 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 identifier of the Document Template.
- To get the template ID:
- format
- 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
- Usage
-
- Get the object name from the Object Properties
- Get the template name from the Document Template
- Get the record ID from the incoming parameters
- Use result.getID() to retrieve the document ID
- Pass it to the getDocument method to get a PlatformFileBean that contains the document
- Example
- This example calls generateDocument on a case to create an HTML document.
String printTemplate = ""; // Code this value String recordID = ""; // Get this value from incoming parameters ... Result result = Functions.generateDocument("cases", recordID, printTemplate, 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 { String doc_id = result.getID(); PlatformFileBean file = Functions.getDocument(doc_id); // Additional business logic... }