Difference between revisions of "GetDocument"

From AgileApps Support Wiki
imported>Aeric
(Created page with "{{subst: Java API}}")
 
imported>Aeric
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:__apiName__}}
{{DISPLAYTITLE:getDocument}}
Description...
Retrieves a document specified by its ID.


;Syntax:
;Syntax:
:<syntaxhighlight lang="java" enclose="div">
:<syntaxhighlight lang="java" enclose="div">
Result result = Functions.__apiName__(String objectName, String fields, String criteria);
Result result = Functions.getDocument(String documentID);  
Result result = Functions.__apiName__(String objectName, String fields, String criteria
                            [, Parameters params] );
Result result = Functions.__apiName__(String objectName, String fields, String criteria);
Result result = Functions.__apiName__(String objectName, String fields, String criteria,
                            String sortBy, String sortOrder,
                            String sortBy2, String sortOrder2,
                            int offset, int numberOfRows);
</syntaxhighlight>
</syntaxhighlight>


;Parameters:
;Parameters:
:;objectName:The object name or identifier
:'''documentID -''' The ID of a document stored in the platform.
:;fields:A comma-separated list of names of the fields to retrieve
:;criteria:A [[JAVA API:Filter Expressions in JAVA APIs|filter expression]] that specifies records to select.
:;params: An optional [[Parameters Class|Parameters]] object that contains additional parameters:
:::*''' param -''' ...


;Returns:
;Returns:
:[[Result Class|<tt>Result</tt>]] object<br/>
:[[Result Class|<tt>Result</tt>]] object that contains the document in the form of a {{^PlatformFileBean}}.
--or--
:An integer containing ...
:A string containing ...
 
;Throws:
:Exception


;Usage:
;Usage:
::* Find the object name in the [[Object Properties]]
:# Use <tt>result.getParameters()</tt> to get the params from the Result object.
::* Get the record ID from the [[incoming parameters]]
:# Call <tt>getPlatformFileBean()</tt> on the params, passing the document ID as a string.
::* Use <tt>result.getID()</tt> to retrieve the returned ID
:# If needed, call <tt>getBytes()</tt> on the PlatformFileBean to get document content in a byte array.
::* Pass it to the {{^Fcn}} <tt>getXyz()</tt> method to get a {{^PlatformFileBean}} or __other item__


;Example:This example ....
;Example:This example logs the size and name associated with a document.
:<syntaxhighlight lang="java" enclose="div">
:<syntaxhighlight lang="java" enclose="div">
...
Result result = Functions.getDocument(documentId);
Parameters params = result.getParameters();
PlatformFileBean file = params.getPlatformFileBean(documentId);
byte[] bytes = file.getBytes();
String msg = "Name:"+file.getName()+", size:"+file.getEncodedFileContent().length();
Logger.info(msg, "Document");
</syntaxhighlight>
</syntaxhighlight>
<!--ACTIVATE THE CATEGORY BELOW FOR MAIN "COLLECTION" PAGES (not for individual methods)
<!--ACTIVATE THE CATEGORY BELOW FOR MAIN "COLLECTION" PAGES (not for individual methods)

Latest revision as of 00:37, 17 January 2014

Retrieves a document specified by its ID.

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

Result result = Functions.getDocument(String documentID); </syntaxhighlight>

Parameters
documentID - The ID of a document stored in the platform.
Returns
Result object that contains the document in the form of a PlatformFileBean.
Usage
  1. Use result.getParameters() to get the params from the Result object.
  2. Call getPlatformFileBean() on the params, passing the document ID as a string.
  3. If needed, call getBytes() on the PlatformFileBean to get document content in a byte array.
Example
This example logs the size and name associated with a document.
<syntaxhighlight lang="java" enclose="div">

Result result = Functions.getDocument(documentId); Parameters params = result.getParameters(); PlatformFileBean file = params.getPlatformFileBean(documentId); byte[] bytes = file.getBytes(); String msg = "Name:"+file.getName()+", size:"+file.getEncodedFileContent().length(); Logger.info(msg, "Document"); </syntaxhighlight>