Announcement

Collapse
No announcement yet.

Error in array/IndexOf

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error in array/IndexOf

    Hi.

    When it doesn't find the value in the array it is not returning null. Is returning something else.

    To test this I wrote this script

    $testList = list(1,2,3,4,5,6);

    $verify = 9;

    $position = array\indexOf($testList, $verify);


    $answer = 'unanswered';
    ifThen($position > 0,
    $answer = '>0');

    ifThen($position == 0,
    $answer = '0');

    ifThen($position == null,
    $answer = 'null');

    ifThen($position == '',
    $answer = 'nothing');


    //********** INICIO LOG DE PRUEBAS
    $tstDescription = null;
    $tstName = "Test 1 ";
    $tstDescription = string\concatenate(
    ' $position ', $position ,
    ' $verify ', $verify ,
    ' $answer ', $answer ,
    ' $testList ', array\join($testList, '-') ,
    " ");
    $tstLogId = record\create('LogPruebas',
    'name', $tstName,
    'description', $tstDescription);
    //*********** FIN LOG DE PRUEBAS​


    I ran this script changing the line with the verify line to

    $verify = 1;
    $verify = 3;
    $verify = 9;

    And he output was:

    Click image for larger version

Name:	image.png
Views:	146
Size:	7.9 KB
ID:	97727

    So when $verify = 9; ir shows $position apparentely as a null, but when I ask if $position == null, it doesn't make $answer = 'null'


  • #2
    Code:
    $index = array\indexOf(list(0, 1), 2);
    
    if ($index == null) {
        output\print('is null');
    }​
    prints "is null"

    Comment


    • #3
      The version is required in bug reports. https://forum.espocrm.com/forum/bug-...o-report-a-bug I move the post out of bug reports.

      Comment


      • #4
        Hey for me it works just fine...
        Click image for larger version

Name:	image.png
Views:	116
Size:	35.7 KB
ID:	97763

        Comment


        • #5
          Tried also copy your code and it works fine for me

          Click image for larger version

Name:	image.png
Views:	111
Size:	41.1 KB
ID:	97766
          Attached Files

          Comment

          Working...
          X