Groovy Script: handling uploaded files

When an Expression Rule of type File calls a Groovy script, the script is provided with the implicit object 'compressedFile'.  This example shows how the compressedFile object can be used.

This Expression Rule uses the Groovy script 'LastLine' to return the last line of the file, and sets the dataItem 'lastLine' to the returned value:

Type:  File
IF:      some condition e.g. File.hint=="hint"
THEN:  SetDataItem("lastline", str(ExecuteCustomObject("LastLine")))

The LastLine script uses the implicit object 'compressedFile':

You can see that the ExecuteCustomObject function gives you a simple way to expand Expression Rules using a scripting environment with complete access to the Platform SDK.  And this example shows that you can do a lot in just a few lines of Groovy.