title: How to set variable in Script Task when Value is an Array in Camunda
body: <p>I am trying to merge two array into one array of Object and Set this Object as Variable for further use.
  Using Script Format “javascript” and script type “Inline script”.</p>
  <p>below is the code that I was trying.</p>
  <pre><code>var A_Group = execution.getVariableTyped(&quot;A_Group&quot;, true).getValue()
  var B_Group = execution.getVariableTyped(&quot;B_Group&quot;, true).getValue()
  var groupList = new Array
  for(var i=0; i&lt;A_Group.length;i++){
      for(var j=0;j&lt;B_Group.length;j++){
         groupList.push({ 
          &quot;A_Group&quot;  : A_Group[i],
          &quot;B_Group&quot;  : B_Group[j]
      });
      }
  }
  execution.setVariable(&quot;GroupList&quot;, groupList);
  </code></pre>
  <p>But whenever flow reached this script it shows this error</p>
  <p><em>500 Internal Server Error</em></p>
  <pre><code>{
      &quot;type&quot;: &quot;RestException&quot;,
      &quot;message&quot;: &quot;Cannot instantiate process definition Process_11qsgp3:3:0c411f07-4944-11eb-9f3b-5c80b61f42fc: 
      Cannot serialize object in variable 'GroupList': SPIN/DOM-XML-01030 Cannot create context&quot;
  }
  </code></pre>
  <p>Please, any lead will be helpful. Ask in comment if not clear.</p>
  <p>Thank you !</p>