Start of changeIBM FileNet P8, Version 5.2.1            

Example: Bulk action to download document content

This JavaScript example downloads the document content to a specified directory.

Adapt the following items in the script example:

Output directory Change the output directory in the script. Because the JavaScript code is executed on a Content Platform Engine server, the content download directory that you specify must satisfy the following requirements:
  • It exists on the server.
  • It is one to which the server has write permissions.
After the query runs, look at the output folder to verify that the document content was downloaded as expected.

Query example

SELECT TOP 100 This FROM Document

Script example

importClass(Packages.com.filenet.api.collection.ContentElementList);
importClass(Packages.com.filenet.api.core.ContentTransfer);
importClass(java.io.FileOutputStream);
importClass(java.io.InputStream);
importClass(java.lang.Byte);

function OnCustomProcess (CEObject)
{
   CEObject.refresh();
   var ce = CEObject.get_ContentElements();
   if(ce.size() > 0)
   {   
        var ct  = ce.get(0); 
        var folderName = "C://Temp/Content/"; 	// output directory 
        this._downloadContent(folderName, ct);
   }
}
 
function _downloadContent(folderName, ct)
{
    var out = new FileOutputStream(folderName + ct.get_RetrievalName());
    var docLen = ct.get_ContentSize().intValue();
    var buf = java.lang.reflect.Array.newInstance(Byte.TYPE, docLen)
    var stream = ct.accessContentStream();
 
    stream.read(buf, 0, docLen);
    out.write(buf);
    out.flush();
    stream.close();
    out.close();
}

            


Last updated: March 2016
p8pcc439.htm

© Copyright IBM Corporation 2017.
End of change