IT Process Automation

  • 1.  How do you create a Value map array process variable?

    Posted Oct 04, 2017 12:50 PM

    Hi,

     

    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;
         return;
    }
    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.

     

    Thanks!



  • 2.  Re: How do you create a Value map array process variable?
    Best Answer

    Posted Oct 04, 2017 01:20 PM

    #valuemaparray, #caprocessautomation4.3

    Hi Grant,

     

    The way I solve this is actually funny.

     

    Process.valueMapArray = new Array(newValueMap());

     This will create the array that you want, but with one item (the newValueMap()), so you just follow it with a shift() or pop()

    Process.valueMapArray = new Array(newValueMap());
    Process.valueMapArray.pop();

     

    And it will be an empty array as you want

     

     

    Cheers



  • 3.  Re: How do you create a Value map array process variable?

    Posted Oct 04, 2017 01:41 PM

    Thank you Marcel,

     

    That seems to have worked!  



  • 4.  Re: How do you create a Value map array process variable?

    Posted Apr 30, 2018 04:37 PM

    Nice write up Marcel! You helped me out too there.