AgileApps Support Wiki Pre Release

Difference between revisions of "Java API:Document Management"

From AgileApps Support Wiki
imported>Aeric
imported>Aeric
Line 1: Line 1:
The Document Management [[Java API]]s  are used to generate and manage documents.
The Document Management [[Java API]]s  are used to generate and manage documents.
== Access Documents ==
:* <tt>[{{DOCHOST}}/javadocs/com/platform/api/Functions.html#getDocument(java.lang.String) getDocument](String id)</tt>
::Get a document by specifying its ID.
:* <tt>[{{DOCHOST}}/javadocs/com/platform/api/Functions.html#getDocumentByTitle(java.lang.String) getDocumentByTitle]("title")</tt>
:: Get document by name, or all documents if an empty string is passed.
== generateDocument ==
== generateDocument ==
{{:generateDocument}}
{{:generateDocument}}
== Access Documents ==
:*
:*
<noinclude>
<noinclude>
__FORCETOC__
__FORCETOC__

Revision as of 02:59, 24 September 2013

The Document Management Java APIs are used to generate and manage documents.

Access Documents

Get a document by specifying its ID.
Get document by name, or all documents if an empty string is passed.

generateDocument

Generates a document based on an HTML Document Template.

Syntax

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

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

                                   String templateID, String format);

</syntaxhighlight>

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:
  • Go to 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
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
Usage
Example
This example calls generateDocument on a case to create an HTML document.
<syntaxhighlight lang="java" enclose="div">

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

} </syntaxhighlight>