Skip to main content
Known Participant
Mar 9, 2023 10:09 AM UTC
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

    4 replies

    pragnaj0001
    Inspiring
    Mar 9, 2023 10:40 AM UTC

    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
    Brainy
    Mar 9, 2023 2:59 PM UTC

    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
    Inspiring
    Mar 14, 2023 6:33 PM UTC

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

    - Aditya
    nicholasw609
    Participating Frequently
    Mar 15, 2023 3:22 AM UTC

    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!