cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Axeda Groovy Script: Handling uploaded files

No ratings

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

    }

}

Version history
Last update:
‎May 26, 2016 05:37 PM
Updated by:
Labels (2)