error in for each with a "average" query

HI!

So i am trying to get an average rating from my database and insert it in a foreach so i can display the average rate for all the items that are populated using the same foreach. Here is part of the code:

           ),
                  a!forEach(
                    items: local!filtered,
                    expression: 
                    a!localVariables(
                      local!queryrating: rule!AS_Get_Rating(fv!item.id),
                      local!ratestar: local!queryrating.rating_average,
                    a!boxLayout(
                        label: "",

but i get this error: Interface Definition: Expression evaluation error at function a!forEach [line 63]: Error in a!forEach() expression during iteration 2: Expression evaluation error: Invalid index: Cannot index property 'rating_average' of type String into type List of Variant

which is weird because "rating_average" is of type number, any help?

  Discussion posts and replies are publicly visible

Parents Reply
  • In your sample code you are assign the value of rating_average to your local local!ratestar, however at some moment as you mentioned that value is null thus you are getting the error that you describe, the index() is to ensure that you have a default value for the null situation and the toInteger() is to guarantee the expected type. 

    Probably you are handling the null  local!ratestar in your code, so if you add the code that I send as an example to your local and handle the null you should not have error.

    Hope that helps,

    Acacio B.

Children