Workflow scripted elements, actions, and policies require scripting of common file system tasks. You can cut, paste, and adapt these examples into your scripted elements.

Add Content to a Simple Text File

The following JavaScript example adds content to a text file.

var tempDir = System.getTempDirectory() ;
var fileWriter = new FileWriter(tempDir + "/readme.txt") ; ; 
fileWriter.writeLine("File written at : "+new Date()) ; 
fileWriter.writeLine("Another line") ; 
fileWriter.close() ;

Obtain the Contents of a File

The following JavaScript example obtains the contents of a file from the Orchestrator server host machine.

var tempDir = System.getTempDirectory() ;
var fileReader = new FileReader(tempDir + "/readme.txt") ; ; 
var fileContentAsString = fileReader.readAll(); 
fileReader.close() ;