Freemarker Script: Greater than 4000 char, exceeding historic variable instance DB insert

Solved in org.apache.commons.io.IOUtils cannot be found when task runs as Job. (see that post for more info about why the previous code in this thread fails)

Working code snippet allowing you to load a resource from a deployment:

var processDefinitionId = execution.getProcessDefinitionId();
var deploymentId = execution.getProcessEngineServices().getRepositoryService().getProcessDefinition(processDefinitionId).getDeploymentId();
var resource = execution.getProcessEngineServices().getRepositoryService().getResourceAsStream(deploymentId, 'content.txt');

var Scanner= Java.type("java.util.Scanner");
scannerResource = new Scanner(resource, "UTF-8");

var content = scannerResource.useDelimiter("\\Z").next();

scannerResource.close();

Where content is the variable with your resource’s content