Skip to main content
Question

SPIN/DOM error in workflow after moving to PROD

  • May 30, 2024
  • 5 replies
  • 129 views

MWitczak
Hero (Customer)
Forum|alt.badge.img+10

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 = workset[i].ActivitySeq;
qty = workset[i].Quantity;

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

}

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

 

From PROD:

 

From TEST (successful execution with same data):

 

5 replies

Forum|alt.badge.img+9
  • Hero (Employee)
  • 137 replies
  • May 31, 2024

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 

 


MWitczak
Hero (Customer)
Forum|alt.badge.img+10
  • Author
  • Hero (Customer)
  • 68 replies
  • May 31, 2024

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.


Forum|alt.badge.img+7
  • Sidekick (Partner)
  • 50 replies
  • May 31, 2024

 

@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.


Forum|alt.badge.img+9
  • Hero (Employee)
  • 137 replies
  • June 3, 2024

@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

 


MWitczak
Hero (Customer)
Forum|alt.badge.img+10
  • Author
  • Hero (Customer)
  • 68 replies
  • June 3, 2024

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.