ScriptTask: Unable save javascript json object as variable

I’m trying to run a javascript code using the script task. We are using the secure javascript module.
The script we are trying to execute is

var batchExport = {};
batchExport.exportProfile = "testProfile"; 
batchExport.batchName = "rrrrrr";


When we are trying to execute this getting error like,

org.flowable.common.engine.api.FlowableException: Couldn't serialize value '[object Object]'

Can someone help on how to resolve this.


One way to work around this is as follows:

var batchExport = JSON.parse(execution.getVariable(“aaa”));

1 Like

Hi @maudrid,
Thanks for the workaround.
But i feel like there is should be some native support for this.

The problem is not with flowable.
Java does not know how to serialise a javascript object.

I never said the problem is with flowable. I just expressed that it would be helpful if flowable had some kind of support to handle the javascript json objects.
We are using the secure javascript until and so the rhino engine is at the background running the scripts.
As I understand, rhino parses the javascript objects inside the instance of a NativeObject. NativeObject by itself is Serializable(from doc). But because of some flowable secure javascript scope object reference, the serialization is failing. In this case it kind of seems a problem on the flowable end.
I’m sorry if I got anything wrong.