Automation

The Automation is a pervasive aspect of the LogicalDOC platform and represents the way you have to program things using a simple scripting language. Sometimes you wish LogicalDOC to execute your own logic when something special happens during a workflow or in reaction to specific events occurrend inside the repository: with the Automation you can inject your own algorithm to take the proper actions automatically. Many objects support Automation and allow you to define custom Automation's scripts(folders, workflows, emails, etc.)

Please look at the Automation Syntax Guide to familiarize with the syntax. You may also look at the Automation Snippets.

In your automation scripts you can reference the following variables(some of them are only available in certain scopes):

GENERALLY AVAILABLE
Object Methods Description
nl   represents the new line
product   name of the product
locale   current locale
CURRENT_DATE   current date
tenantId   identifier of the current tenant
dictionary   map with all the variables(name > value)
log print(String message) prints a message in the system output
debug(String message) prints a debug message in the log file
info(String message) prints an informative message in the log file
warn(String message) prints a warning message in the log file
error(String message) prints an error message in the log file
I18N format(String key, String value) prints the translation of a key and expands one optional value
format(String key, String value1, String value2) prints the translation of a key and expands 2 optional values
format(String key, String value1, String value2, String value3) prints the translation of a key and expands 3 optional values
format(String key, String value1, String value2, String value3, String value4) prints the translation of a key and expands 4 optional values
format(String key, String value1, String value2, String value3, String value4, String value 5) prints the translation of a key and expands 5 optional values
format(String key, String[] values) prints the translation of a key and expands an array of optional values
DateTool format(Date date, boolean time) formats a date for the current locale optionally including the time
currentTime() instantiates a new Date object representing the current time
DocTool downloadUrl(long docId) prints the download Url for the given document's id
downloadUrl(Document doc) prints the download Url for the given document
downloadUrl(History history) prints the download Url for the given event
downloadTicket(long docId, boolean pdfConversion, Integer expireHours, Date expireDate) creates and prints the a download ticket for the given document or it's PDF conversion
displayUrl(long tenantId, long docId) prints the display Url for the given document's id
displayUrl(Document doc) prints the display Url for the given document
displayUrl(History history) prints the display Url for the given event
store(Document doc) stores a document
store(Document doc, String username) stores a document in the name of the given user
move(Document doc, String targetPath, String username) moves a document in a target path
copy(Document doc, String targetPath, String username) copies a document in a target path
Folder createPath(Document doc, String targetPath) creates a path, if the path is relative it is computed from the document's folder. Returns the created folder
Document convert(Document doc, String format, Sring username) converts a document into a different format in the name of the given user. Returns the created document
displayFileSize(Long size) prints a formatted file size
getPath(Document doc) prints the path of the given document
FolderTool displayUrl(long tenantId, long folderId) prints the display Url for the given folder's id
displayUrl(Folder folder) prints the display Url for the given folder
displayUrl(FolderHistory history) prints the display Url for the given event
getPath(Long folderId) prints the path of the given folder
ClassTool Object newInstance(String classname) instanciates the given class. Returns the created instance
SystemTool exec(String commandline) executes a given command
exec(String commandline, String path) executes a given command from a specific path
execGetOutput(String commandline) executes a given command and returns the output
execGetOutput(String commandline, String path) executes a given command from a specific path and returns the output
MailTool sendDocuments(Collection<Document> documents, String from, String to, String subject, String message) sends a collection of documents by email to a recipient
sendDocuments(Collection<Document> documents, String from, Collection<String> to, String subject,
String message)
sends a collection of documents by email to a set of recipients
sendDocument(Document document, String from, String to, String subject, String message) sends a document by email to a recipient
sendDocument(Document document, String from, Collection<String> to, String subject, String message) sends a document by email to a set of recipients
sendMessage(long tenantId, String from, String to, String subject, String message) sends an email to a recipient
sendMessage(long tenantId, String from, Collection<String> to, String subject, String message) sends an email to a set of recipients
BarcodeTool extract(Document doc, String possibleFormats) extracts the barcodes inside a given document, you can optionally filter by format("CODE_39,EAN_8")
extract(String filePath, String tenant, String possibleFormats) extracts the barcodes inside a given file, you can optionally filter by format("CODE_39,EAN_8")
extractBarcode(Document doc, String possibleFormats) extracts the first barcode inside a given document, you can optionally filter by format("CODE_39,EAN_8")
extractBarcode(String filePath, String tenant, String possibleFormats) extracts the first barcode inside a given file, you can optionally filter by format("CODE_39,EAN_8")
StampTool stamp(Document doc, String stampName, User user) applies a stamp in the given document in the name of the given user
stamp(Document doc, String stampName, User username) applies a stamp in the given document in the name of the given user
SignTool sign(Document doc, User user, String reason, String password) digitally signs a document with the user's digital certificate
sign(Document doc, String username, String reason, String password) digitally signs a document with the user's digital certificate
AutomationTool execute(String routine, long tenantId, Map<String, Object> dictionary) executes a routine in the same execution thread. Returns the routine result
fork(String routine, long tenantId, Map<String, Object> dictionary) executes a routine in a new execution thread
AVAILABLE WHEN REACTING TO EVENTS
event   the current event
document   the document associated to the current event(if any)
folder   the folder associated to the current event(if any)
AVAILABLE INSIDE WORKFLOW
candidates   list of the current task's candidate users
documents   list of the attached documents
task   the current task
taskName   name of the current task
initiator   the user that started the worflow
workflow   name of the workflow
processId   identifier of the current process
definitionId   identifier of the process definition
actions   list of possible actions(transitions) declared for the current task
assignee   user assigned to the current task
WorkflowTool complete(Task task, String transition) completes a task with the given transition
claim(Task task, String username) claims a task for the given user
completeUrl(Task task, String transition, User user) prints the Url to complete the task with a specific transition
claimUrl(Task task, User user) prints the Url to claim a task for a specific user
addNote(Task task, String note) adds a new note on the given task instance
getHistories(String processId, String eventName) gets the list of events of a given process instance, you can optionally filter for a given event name('task.start', 'task.end', ...)
getLastHistory(String processId, String eventName) gets the last event of a given process instance, you can optionally filter for a given event name('task.start', 'task.end', ...)