AnsweredAssumed Answered

How do you create a Value map array process variable?

Question asked by Grant Bruneau Champion on Oct 4, 2017
Latest reply on Apr 30, 2018 by j.barger



I'm trying to add value maps to a process array but am receiving the error "msg.array.element.mismatch".  If i declare a local array I'm able to populate each element with a valuemap.  However, when doing the same with a Process Variable array the mentioned error is returned.


I'm trying to rebuild the getFormRateItemValues operator so that it's able to parse a large amount of data. Currently, if Service Catalog form has a table with several column and a user submits a request with ~100 rows, the getFormRateItemValues operator will fail as it's not able to parse the response.


Here is the code in the out of the box operator. (Which may fail on large requests)

* Create an array of ValueMap objects that hold the form IDs/Values as a key/value pair
* Set a Process variable to hold this local array object to make the form IDs/Values accessible

// declarations
var  l_numFields = 0;
var l_arrayFormIDsValues = new Array();

if (Process[OpName].Result == 1) {
     Process.Successful__ = "TRUE";

     // get the number of form fields contained in the form
     l_numFields =  Process[OpName].SoapResponseData.getFormRateItemValuesReturn[0].form[0].form.length;
     logEvent(0, "GetFormFieldsBySubsID", "Number of fields in form: " +  l_numFields);

       for each form field, store the field ID and the field Value in a ValueMap object
       create an array of these ValueMap objects
for(var i = 0; i <l_numFields; i++) {
     vmap = newValueMap();
     vmap.strKey = Process[OpName].SoapResponseData.getFormRateItemValuesReturn[0].form[0].form[i].ID[0].text_;
     vmap.strValue = Process[OpName].SoapResponseData.getFormRateItemValuesReturn[0].form[0].form[i].value[0].text_;

     l_arrayFormIDsValues[i] = vmap;

// set a Process variable to hold the local array object to make the form IDs/Values accessible
Process.arrayFormResults = l_arrayFormIDsValues;
else {
     logEvent(0, "ERROR",   "SOAP call getFormRateItemValues() failed");
     throw "SOAP call getFormRateItemValues() failed";


I'm trying to change this so that it loops through the returned data 50 lines at a time.  Here's what I have so far, this code is not working and returning the mentioned error. This code is in a javascript operator contained within a loop.  The loopStart and loopEnd variables are incremented up by 50 after each run.

for(var i = Process.loopStart; i < Process.loopEnd && i < Process.getFormRateItemValuesLength; i++) {
  vmap = newValueMap();
  vmap.strKey =    Process.getFormRateItemValues.SoapResponseData.getFormRateItemValuesReturn[0].form[0].form[i].ID[0].text_;
  vmap.strValue = Process.getFormRateItemValues.SoapResponseData.getFormRateItemValuesReturn[0].form[0].form[i].value[0].text_;

  Process.arrayFormResults[i] = vmap;


However, if I declare a local array then set the process array equal to the local array it will work, but I can't figure out how to get it to work with a loop...


Any help is appreciated.