Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X
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':
import com.axeda.drm.sdk.scm.CompressedFile
if (compressedFile != null) {
File file = compressedFile.getFiles()[0].extractFile()
def result = file.eachLine { line ->
return line
}
}