Skip to main content

I have a workflow that sums labor hours by activity sequence from a Schedule of Work and writes those summed values to the Activity Estimate.  The workflow works as expected in our TEST environment.  I added the workflow to an Application Configuration Package and imported into our PROD environment, and the workflow does not function (generates the error “Cannot serialize object in variable ‘result’: SPIN/DOM-XML-01030 Cannot create context).  The same data generates a different result.

 

Could this be a permissions issue?  It fails for all users (I don’t have access to the app owner though)

 

Here’s the code for the ‘result’ variable:

 

var workset = execution.getVariable("Reference_SchOfWorkEstimateResourceSummary_Set");
var myMap = {};

var ArrayList = Java.type('java.util.ArrayList');
var activitySeqlist = new ArrayList();

for (var i = 0; i < workset.length; i++) {
    
actSeq = workseti].ActivitySeq;
qty = worksetti].Quantity;

if (actSeq  in myMap ) {
   myMapiactSeq] = myMap/actSeq] + qty;
} else {
    myMapbactSeq] = qty;
activitySeqlist.add(actSeq);
}

}

execution.setVariable("result", myMap) ;
execution.setVariable("actiseqens", activitySeqlist);

 

From PROD:

 

From TEST (successful execution with same data):

 

You could try using a Java HashMap object instead of a JavaScript object for the “result”

 

First, define a HashMap class variable:

var HashMap = Java.type('java.util.HashMap');

Next, replace any declarations of a JavaScript object as such:

//var varName = {};
//Replace with:
var varName = New HashMap();

When setting properties, use the put method:

//varName.propertyName = value;
//Replace with:
varName.put('propertyName', value);

 

There was a similar case discussed in community you may be able to use as a reference 

 


Thank you @kamnlk.  I’ll see if I can get this to work using HashMap.  I’m still unsure though why the same data input into the same workflow produces a different result between our TEST and PROD environments.  If I can get the HashMap to work hopefully that renders that question moot.


 

@kamnlk 

Thanks for providing this workaround. This works fine till I do execution.setVariable(‘...’, <hashmap or arraylist>);

 

But in the next Script task, if I try to retrieve this HashMap or ArrayList from the execution variable, it returns null everytime.

 

So, when I do - var a = execution.getVariable(‘...’);

or just directly try to access the variable, it returns null.

 

Do you also experience the same?

 

Thanks in advance.


@Rohit 

I have not experience that issue im afraid, it should work without an issue.

below is an example i came up with hope it clears it up

in here im accessing the elements from a second task and adding new elements to it

 


Unfortunately, I was unable to get HashMap to work.  On the Camunda community pages, there are several persons that have had this same issue happen, and unfortunately no one has found a root cause or a solution.  There has to be some difference between the environments that causes this (perhaps some missing Java class or something), but I cannot find it.


Reply