Skip to main content
May 25, 2023
Solved

Invalid index (1) for list: valid range is empty

  • May 25, 2023
  • 2 replies
  • 0 views

Hi Team,

How do we check if the dictionary has one of the value as null.

ERROR

----------

Expression evaluation error at function a!forEach [line 8]: Error in a!forEach() expression during iteration 2: Expression evaluation error in rule 'config_temp': Invalid index (1) for list: valid range is empty

Eg:

dict1:
{

field1:"value1",

field2:"value2",

field3:""

}

Now, in my logic I'm trying to get each field value and storing in a variable.

index(local!data,"field3",null())

    Best answer by mathieud0001

    a!localVariables(
      local!dictionary: {
        field1: "value1",
        field2: "value2",
        field3: null,
        field4: "value4",
        field5: null
      },
      reject(
        fn!isnull,
        a!forEach(
          items: a!keys(cast(typeof(a!map()), local!dictionary)),
          expression: a!localVariables(
            local!value: index(local!dictionary, fv!item, null),
            if(a!isNullOrEmpty(local!value), fv!item, null)
          )
        )
      )
    )

    2 replies

    mathieud0001
    Brainy
    May 25, 2023

    a!localVariables(
      local!dictionary: {
        field1: "value1",
        field2: "value2",
        field3: null,
        field4: "value4",
        field5: null
      },
      reject(
        fn!isnull,
        a!forEach(
          items: a!keys(cast(typeof(a!map()), local!dictionary)),
          expression: a!localVariables(
            local!value: index(local!dictionary, fv!item, null),
            if(a!isNullOrEmpty(local!value), fv!item, null)
          )
        )
      )
    )

    May 26, 2023

    Thanks!