IT Process Automation

  • 1.  Javascript split string method is not working in javascript operator

    Broadcom Employee
    Posted Jan 12, 2016 03:14 PM

    Hi Community,

     

    I have one javascript operator with the following code.

     

    var jobssel = new Array();

    var jobsstring = Process.jobs;

    if (jobsstring.indexOf(",") == -1){

      jobssel.push(jobsstring);

    }else{

      jobssel.push(jobsstring.split(/,/));

    }

    for (i = 0; i < jobs.length; i++){

      var jobsValueMapSelected = newValueMap();         // Crea valuemap de jobsSelected

      var items = jobssel[i].split("@");

      for(j = 0; j < items.length; j++){

        switch(j){

          case 0:

            jobsValueMapSelected.jobId = items[j];

            break;

          case 1:

            jobsValueMapSelected.jobName = items[j];

            break;

          case 2:

            jobsValueMapSelected.domainName = items[j];

            break;

          case 3:

            jobsValueMapSelected.Server = items[j];

            break;

          case 4:

            jobsValueMapSelected.domainUrl = items[j];

            break;

          case 5:

            jobsValueMapSelected.packageName = items[j];

            break;

          case 6:

            jobsValueMapSelected.packageVersion = items[j];

            break;

          case 7:

            jobsValueMapSelected.procedureName = items[j];

            break;

        }

      }

      Process.size = Process.ListJobsSelected.length;

      Process.ListJobsSelected[Process.ListJobsSelected.length] = jobsValueMapSelected; // Agrega valuemap a array de objetos

    }

    Process.e=0;

     

    When I run the process this operator cancel with the following error "Failed to execute code:  -- TypeError: Cannot find function split. (#11)".

     

    I test also with jobsstring.split(",") with the same behaviour.

    The value of Process.jobs is:

     

    B7F919D67E774DD1BB803104CB4364A1@DummyPackage 1.0:Install@W12R2SQLSDM141@W12R2EEMITAM141@DummyPackage@1.0@Install,B7F919D67E774DD1BB803104CB4364A1@DummyPackage" rel="nofollow" target="_blank">http://192.168.159.62/DSM_WebService/mod_gsoap_utf8.dll@DummyPackage@1.0@Install,B7F919D67E774DD1BB803104CB4364A1@DummyPackage 1.0:Install@W12R2SQLSDM141@W12R2EEMITAM141@DummyPackage@1.0@Install" rel="nofollow" target="_blank">http://192.168.159.62/DSM_WebService/mod_gsoap_utf8.dll@DummyPackage@1.0@Install

     

    Anybody could you help me about this error?

     

    Thanks in advance,

    Rafa

     

     

     



  • 2.  Re: Javascript split string method is not working in javascript operator
    Best Answer

    Broadcom Employee
    Posted Jan 12, 2016 03:35 PM

    Rafa,

     

    The line number (#11) in the error message is pointing to the second "split" method, here:

     

      var items = jobssel[i].split("@");

     

    not the one you have highlighted.  After you execute the first split,

     

    jobssel.push(jobsstring.split(/,/));

     

    jobssel[0] is an array, not a string.  When you try to execute that second split, javascript is trying to find a "split" method for the array type, and gives you the error.



  • 3.  Re: Javascript split string method is not working in javascript operator

    Broadcom Employee
    Posted Jan 12, 2016 04:16 PM

     

     

     

    Thanks Bill, I was determined that the error was in the first split, as you say the second split is the real problem, is not a string is an array.

     

    Rafa