IBM BPM, V8.0.1, All platforms > Programming IBM BPM > Developing using the JavaScript API > Samples

Work with document attachments

Document attachments can be associated with process instances. These can be added through coach controls or through programmatic additions.

The relevant JavaScript components are:

TWDocument

The description of a document.

tw.system.findDocumentByID()

Finds a document from its ID.

TWProcessInstance.documents

An array of TWDocument objects associated with an instance of a process.

TWProcessInstance.addDocument()

Adds a document to a process instance.

TWProcessInstance.findDocuments()

Locates documents associated with the current instance.

The addDocument() function will not work when called from JavaScript locally coded in a BPD activity but works fine when coded in a general service.


Use the addDocuments() method

The addDocuments() method has the following parameters:

type (String)

Either TWDocument.Types.URL or TWDocument.Types.File.

name (String)

Name of the document.

fileLocation (String)

The path to the file on the server or URI.

hideInPortal (Boolean)

A flag which describes whether or not the document is to be visible in the process portal.

createdBy (TWUser)

properties (Map)

The following code sample illustrates how to use the addDocuments() method.

var myMap = new tw.object.Map();
tw.system.currentProcessInstance.addDocument(
  TWDocument.Types.File,   "name",   "C:\\Projects\\WLE\\Images\\ibm.jpg",   hide,   user,   myMap);

Samples