Working with documents in a workflow

Rulecube contains some specialized methods that you can use within a workflow to handle uploaded or generated workflow documents.

Workflow.getDocuments()

Get all documents from the database that are related to the current workflow.

Returns a list of WorkflowDocument.

Workflow.getDocument(documentTypeName)

Get a document from the database with the given documentTypeName.

The documentTypeName parameter should match one of the document types defined in the workflow Settings.

Returns a WorkflowDocument.

Workflow.getDocumentDataUri(documentTypeName)

Get a document from the database as a data URI.

The documentTypeName parameter should match one of the document types defined in the workflow Settings.

Returns a string.

Workflow.saveDocument(documentTypeName, dataUri, fileName?)

Save a document to the database. This is useful for when you want your application to generate a document and store it.

The documentTypeName parameter should match one of the document types defined in the workflow Settings.

The dataUri parameter is the Base64 data URI of the document.

The fileName parameter is optional and defines the name of the file.

Returns void.

// This assumes there is a Document Type defined in the workflow with the name 'MyDocument'.' 
Workflow.saveDocument('MyDocument', 'data:text/plain;base64,SG93ZHkgcGFydG5lciE=');  

// The 3rd parameter is optional and can be used to set the file name. 
Workflow.saveDocument('MyDocument', 'data:text/plain;base64,SG93ZHkgcGFydG5lciE=', 'MyFile.txt'); 

Last updated