Esempi di Automazione

Suddivide gli stipendi e li invia tramite e-mail ai dipendenti

# split the big payolls pdf in segments of two pages
#set( $paychecks = $SplitTool.splitSelection($document.id, '1-2,3-4,5-6,7-8', 'admin'))

# iterate over the segments, each segment is the paycheck of a single employee
#foreach( $paycheck in $paychecks )
  # parse the segment body and save it in the paycheckBody variable
  #set( $paycheckBody  =  $ContextTool.getBean('DocumentManager').parseDocument($paycheck, null) )
  
  # inspect the body of the segment to understand what is the employee
  # in order to rename the segment file and define the email to send the paycheck to 
  #if($paycheckBody.toUpperCase().contains("JOHN DOE") )
     #set( $newname = $document.title + "-john.pdf")
     #set( $recipient = "john[at]acme.com")
  #elseif($paycheckBody.toUpperCase().contains("MARIO ROSSI")  )
     #set( $newname = $document.title + "-mario.pdf")
     #set( $recipient = "mario[at]acme.com")
  #elseif( $paycheckBody.toUpperCase().contains("ELENA BORGHI") )
     #set( $newname = $document.title + "-elena.pdf")
     #set( $recipient = "elena[at]acme.com")
  #elseif( $paycheckBody.toUpperCase().contains("ALDO MORO") )
     #set( $newname = $document.title + "-aldo.pdf")
     #set( $recipient = "aldo[at]acme.com")
  #end

 # rename the current segment(the user's paycheck pdf)
 $paycheck.setFileName($newname);
 $DocTool.store($paycheck); 

 # notify the employee sending him his paycheck document
 $MailTool.sendDocument($paycheck, null, $recipient, "Acme Paycheck", "Dear employee, please find your new paycheck in attachment of this email.

Remember to save it in your records

Best Regards
Acme paycheck department"); #end

Questo script funziona sul documento attualmente selezionato a cui fa riferimento ls variabile document che è considerato un grande PDF contenente tutti gli stipendi di un mese.

Il documento è suddiviso in segmenti di due pagine, ogni segmento viene salvato come un singolo PDF di busta paga e il suo contenuto viene ispezionato per scoprire a quale dipendente appartiene lo stipendio per inviarlo via e-mail.