Skip to main content
March 9, 2023
Question

Expression evaluation error at function 'contains' parameter 1 [line 986]: Invalid index: Cannot index property 'value' of type String into type List of Variant. Please help

  • March 9, 2023
  • 4 replies
  • 2 views

    4 replies

    pragnaj0001
    March 9, 2023

    I think. Its conversion error. u already converted in items parameter in a!foreach. no need to convert again fv!item in contains function. and convert local!towerpopulate.value to uniform string. try it. 

    abhayd3663
    March 9, 2023

    The forEach expressions returns more than one value and the "value" property expects a single value. If you mean to use this expression for choiceValue instead of value, then it should work.

    adityag9712
    March 14, 2023

    Wrap the first parameter in tostring function and add property function to fetch the value (parameter/column)

    nicholasw609
    March 15, 2023

    Hi! I've looked over your code and it seems like the issue is that your local!towerPopulate variable is not properly typed. Appian is compiling it as a "list of variant", which means that it likely contains your data but the data is set as a list of dfferent values instead of a list the relevant CDT or Map.

    So in your case, it seems like you expect local!towerPopulate to contain the key "value", so I would change your code to index into the local variable at the appropriate key, and cast it to a string.

    As a result, your code should look like this:

    reject(
      fn!isnull,
      a!foreach(
        items: touniformstring(local!currentTowerOwner),
        expression: if(
          contains(
            tostring(
              index(
                local!towerPopulate,
                "value",
                ""
              )
            ),
            touniformstring(fv!item)
          ),
          fv!item,
          {}
        )
      )
    )

    Please let me know if this doesn't work or if you have any further questions!