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.


Access to the file system is limited by default. To access the file server from Orchestrator, see Accessing the Orchestrator Server File System from JavaScript and Workflows.

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() ;

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() ;