Question

SPIN/DOM-XML errors in BPA Workflows

  • 27 March 2024
  • 5 replies
  • 157 views

Userlevel 4
Badge +7

ISSUE/QUESTION: 

When working with Workflows you might encounter errors indicating SPIN/DOM-XML. These errors can be random but when occurred once can occur repeatedly.

The error is 'Cannot serialize object in variable 'var' : SPIN/DOM-XML-01030 Cannot create context'. It is  visible in troubleshoot mode as below.

ENVIRONMENT:  IFS Cloud

AUDIENCE: ALL

RESOLUTION/ANSWER:

When this error is encountered at the point of using an array in a script task, following workaround can be used.

Instead of an array use the java ArrayLIst implementation in the script task. 

For example, the error seen in the image can be overcome by replacing the script with the following. 

var c = new java.util.ArrayList(); 

c.add(‘x’);  

execution.setVariable("abc",c); 

CAUSE: N/A

ADDITIONAL INFORMATION: N/A

SCRIPTS/LOGS: N/A

SOURCE: CS0206101

VERIFIED: NO


5 replies

Userlevel 4
Badge +10

@Lahirumala de Mel 

Is this the same for using javascript array functions like map? 

We had an issue where we tried the following:

 

var orderNos = CustomerOrderSet_Set.map(function(order) {
return order.OrderNos;
}).join(', ');
execution.setVariable("OrderNos",orderNos);

The workflow engine complains with a message “map is not a function” 

This code works perfectly if you try it outside of IFS but when trying to use it on a collection which is a result of an API READ action it gives this error?

 

Can you confirm that we need to do the same type of fix when we want to apply some array functions on a collection coming from a READ action?

We get this error

 

Userlevel 4
Badge +7

.map() is a ES6 syntax in javascript and that is currently not supported form of syntax in workflow

but you should be able to do the same thing using it in the following way 

 

var orderNos = Array.prototype.map.call(CustomerOrderSet_Set, function(order) {  
return order.OrderNos;
}).join(", ");

execution.setVariable("OrderNos",orderNos );

 

Can you give it a try and see 

Userlevel 2
Badge +4

Hi @Lahirumala de Mel @kamnlk,

 

Is there a workaround for storing an object in a process variable? I am experiencing the same issue, but I am not storying an array/ArrayList, I am trying to store an object. I tried storing the object as the 0th index of an ArrayList, but that also fails with a different serialization error message. Note the items collection in the below request is stored as an ArrayList.

 

When Serialization Doesn’t Fail:

 

When Serialization Fails:

Trying to store object as 0th element of ArrayList:

 

Userlevel 2
Badge +4

I believe I was able to solve this issue by using a Java HashMap object instead of a JavaScript object.

 

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

 

Without the HashMap class, I would get a serialization error about 7-8 out of 10 executions. I’ve now ran the same workflow over 25 times with no error, so I believe this method fixes the intermittent serialization issue when dealing with objects.

Userlevel 2
Badge +7

@Lahirumala de Mel @dritter 

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.

Reply