Automation Snippets

Iterate over the documents

#foreach( $doc in $documents )
...
#end

Move the documents into a target folder computed dinamically

#foreach( $doc in $documents )
#set( $fld = $doc.getValue('InvoiceNo') )
$DocTool.move($doc, "/Default/approved/$fld")
#end

The variable fld is declared with the extended attribute InvoiceNo of the document

Apply a stamp in the documents

#foreach( $doc in $documents )
$StampTool.stamp($doc, 'name_of_stamp', 'username')
#end

Print logs (useful for debuging)

#set($now = $ClassTool.newInstance('java.util.Date'))
$log.debug( "debug current date: $DateTool.format($now, true)")

#set($lastEvent = $WorkflowTool.getLastHistory($processId,'task.end'))
$log.info("The user that completed the last task was: $lastEvent.user.fullName")

$log.warn( "Just print a row in warn priority")
$log.error( "Just print a row in error priority")

The log is printed in the file <LDOC_HOME>/repository/logs/automation.log

Send documents to a set of recipients

#set( $recipients= ["This email address is being protected from spambots. You need JavaScript enabled to view it.", "This email address is being protected from spambots. You need JavaScript enabled to view it.", "This email address is being protected from spambots. You need JavaScript enabled to view it."] )
$MailTool.sendDocuments($documents, This email address is being protected from spambots. You need JavaScript enabled to view it.', $recipients, 'subject', 'message');

Execute a routine

$AutomationTool.execute('Routine', $tenantId, $dictionary);