Skip to main content

Frammenti di Automazione

# iterate over the documents
#foreach( $doc in $documents ) 
... 
#end

--------------------------------------------------------------------------------
# move the documents into a target folder computed dinamically
#foreach( $doc in $documents )
  # get the custom attribue 'InvoiceNo' and store it in the fld variable
  #set( $fld = $doc.getValue('InvoiceNo') )
  
  # move the document to a path that is composed by a fixed prefix and the fld value
  $DocTool.move($doc, "/Default/approved/$fld", '_system');
#end

--------------------------------------------------------------------------------
# apply a stamp in the documents
#foreach( $doc in $documents )
 $StampTool.stamp($doc, 'name_of_stamp', 'username');
#end

--------------------------------------------------------------------------------
# get the value of a procedure's invocation parameter
#set($value = $parameters.get('param_name') ) -------------------------------------------------------------------------------- # print logs (useful for debuging) # the log is printed in the file /repository/logs/automation.log #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"); -------------------------------------------------------------------------------- # send documents to a set of recipients #set( $recipients= ["a[at]acme.com", "b[at]acme.com", "c[at]acme.com"] ) $MailTool.sendDocuments($documents, 'sender[at]acme.com', $recipients, 'subject', 'message'); -------------------------------------------------------------------------------- # execute a routine $AutomationTool.execute('Routine', $tenantId, $dictionary, null); -------------------------------------------------------------------------------- # change an extended attribute #foreach( $doc in $documents ) $doc.setValue('attribute_name','attribute_value'); $DocTool.store($doc); #end -------------------------------------------------------------------------------- # adding a note #set($note = $ClassTool.newInstance('core.document.DocumentNote')) #set($noteDao = $ContextTool.getBean('DocumentNoteDAO')) $note.setDocId($document.id); $note.setUsername('admin'); $note.setMessage('test note'); $noteDao.store($note, null); -------------------------------------------------------------------------------- # automatically choose a workflow transition depending on attribute's value #foreach( $doc in $documents ) #set($amount = $doc.getValue("myAttributeName")) #if( $amount > 50000 ) $WorkflowTool.complete($task, "Approve Document") #break #else $WorkflowTool.complete($task, "Reject Document") #break #end #end -------------------------------------------------------------------------------- # reverse foreach #set($max = $opportunityList.size() - 1) #foreach($i in [ $max .. 0 ]) #set($opportunity = $opportunityList[$i]) ... #end -------------------------------------------------------------------------------- # digitally sign a selection of documents #foreach($doc in $documents ) $SignTool.sign($doc, $assignee, "Approved") #end -------------------------------------------------------------------------------- # get the path of files and folders #foreach( $doc in $documents ) #set($docPath = $DocTool.getPath($doc)) $log.info("path of document $doc.fileName: $docPath"); #set($folderPath = $FolderTool.getPath($doc.folder.id)) $log.info("path of folder $doc.folder.name: $folderPath"); #end

Non proprio uno script completo ma una raccolta di frammenti.