Cannot index property 'permittedTeRange' of type String into type List of Variant

a!queryEntity(
                        entity: cons!TEMS_ENTITY_V_TE_DETAILS,
                        query: a!query(
                          paginginfo: a!pagingInfo(1, - 1),
                          logicalexpression: a!queryLogicalExpression(
                            operator: "OR",
                            filters: {
                              a!queryFilter(
                                field: "cafNumber",
                                operator: "=",
                                value: tostring(local!selectedCaf)
                              )
                            }
                          )
                        ),
                        fetchTotalCount: true
                      ).data

Hi All,

I am getting the error "Cannot index property 'permittedTeRange' of type String into type List of Variant". I have attached the code above. Can anyone please help me out.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Seems like you try to fetch data from a field using dot-notation. This does not work in case the query returns no data. Use the index() function instead or make sure the query always returns valid data.

  • Hi ,

    First thing you may not need to use a queryLogicalExpression as it is a single query you can use filter instead. Anyway, are you using this query in a dropdown field where you are trying to index the ''permittedTeRange' filed? where exactly does the error message come from? you can tell this by looking at the error message mostly on a UI. (The line number provided in error is helpful to identify the point of origin of the error)

    Make sure if you are using this for dropdown or multi-select there are no null values fetched from the query. Also if you are using dot notation try using index() function which will prevent errors If the return value is a null set.

  • I don't know why you didn't continue working this in your first thread on the same topic, but this will need to be resolved in the code for your text field, please share that instead.  The queryEntity call above should work fine, although I would prefer the AND operator instead of OR in this scenario (but same result with only one filter).

    As already noted in both threads, you cannot reference a field with dot notation if the data set is empty.  You will need to utilize either the index() function or (my preferred) property() function, in the text field display, as:

    property(local!data,"permittedTeRange",null)