Can anyone explain how to fix this error: Invalid index: Cannot index property 'Status' of type Text into type Text.

A Score Level 1

Hi, 

I am having some issues with a!save. When I use the below code and select a data point on the chart the following error occurs:

Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error: An error occurred while executing a save: java.lang.IllegalArgumentException: Invalid index: Cannot index property 'Status' of type Text into type Text.

 

{
  with(
    local!chartPagingInfo: a!pagingInfo(
      startIndex: 1,
      batchSize: - 1,
      sort: a!sortInfo(
        field: "SubmittedDate",
        ascending: true
      )
    ),
    local!SubmittedDate: null,
    local!datasubset: a!queryEntity(
      entity: cons!NSARequest_Entity_Cons,
      query: a!query(
        aggregation: a!queryAggregation(
          aggregationColumns: {
            a!queryAggregationColumn(
              field: "Status",
              alias: "Status",
              isGrouping: true
            ),
            a!queryAggregationColumn(
              field: "SubmittedDate",
              alias: "SubmittedDate",
              isGrouping: true,
              groupingFunction: "MONTH"
            ),
            a!queryAggregationColumn(
              field: "Id",
              aggregationFunction: "COUNT"
            )
          }
        ),
        pagingInfo: local!chartPagingInfo
      )
    ),
    local!Categories: index(
      local!datasubset.data,
      "SubmittedDate",
      {}
    ),
    local!uniqueCategories: union(
      local!Categories,cast(typeof(local!Categories),{})
    ),
    local!labels: index(
      local!datasubset.data,
      "Status",
      {}
    ),
    local!uniqueLabels: union(
      local!labels,
      cast(
        typeof(
          local!labels
        ),
        {}
      )
    ),
    local!series: a!forEach(
      local!uniquelabels,
      with(
       local!label: fv!item,
        a!chartSeries(
          label: local!label,
          data: a!forEach(
            local!uniqueCategories,
            with(local!intersection: intersection(
                where(local!Categories = cast(typeof(local!Categories), fv!item),0),
                where(local!labels = cast(typeof(local!labels),local!label), 0)
              ),
              if(condition: length( local!intersection) = 0,
                valueIfTrue: 0,
                valueIfFalse: index(index(local!datasubset.data,"Id",{}),local!intersection,0)
              )
            )
          ),
          links: a!dynamicLink( saveInto: { a!save(ri!selectedStatus, fv!item.Status)}
          )
        )
      )
    ),
    a!lineChartField(
      label: "Number of Assets per Month",
      categories: {
        {
          local!uniqueCategories
        }
      },
      series: local!series,
      xAxisTitle: "Month",
      yAxisTitle: "Number of Assets",
      showDataLabels: true
    )
  ),

Can anyone help?

Thanks

Parents
  • Hi,

    You use below code,

     

    {
      with(
        local!chartPagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(
            field: "SubmittedDate",
            ascending: true
          )
        ),
        local!SubmittedDate: null,
        local!datasubset: a!queryEntity(
          entity: cons!NSARequest_Entity_Cons,
          query: a!query(
            aggregation: a!queryAggregation(
              aggregationColumns: {
                a!queryAggregationColumn(
                  field: "Status",
                  alias: "Status",
                  isGrouping: true
                ),
                a!queryAggregationColumn(
                  field: "SubmittedDate",
                  alias: "SubmittedDate",
                  isGrouping: true,
                  groupingFunction: "MONTH"
                ),
                a!queryAggregationColumn(
                  field: "Id",
                  aggregationFunction: "COUNT"
                )
              }
            ),
            pagingInfo: local!chartPagingInfo
          )
        ),
        local!Categories: index(
          local!datasubset.data,
          "SubmittedDate",
          {}
        ),
        local!uniqueCategories: union(
          local!Categories,cast(typeof(local!Categories),{})
        ),
        local!labels: index(
          local!datasubset.data,
          "Status",
          {}
        ),
        local!uniqueLabels: union(
          local!labels,
          cast(
            typeof(
              local!labels
            ),
            {}
          )
        ),
        local!series: a!forEach(
          local!uniquelabels,
          with(
           local!label: fv!item,
            a!chartSeries(
              label: local!label,
              data: a!forEach(
                local!uniqueCategories,
                with(local!intersection: intersection(
                    where(local!Categories = cast(typeof(local!Categories), fv!item),0),
                    where(local!labels = cast(typeof(local!labels),local!label), 0)
                  ),
                  if(condition: length( local!intersection) = 0,
                    valueIfTrue: 0,
                    valueIfFalse: index(index(local!datasubset.data,"Id",{}),local!intersection,0)
                  )
                )
              ),
              links: a!dynamicLink( saveInto: { a!save(ri!selectedStatus, fv!item)}  /* fv!item.Status is not required as fv!item already contains Status only  */
              )
            )
          )
        ),
        a!lineChartField(
          label: "Number of Assets per Month",
          categories: {
            {
              local!uniqueCategories
            }
          },
          series: local!series,
          xAxisTitle: "Month",
          yAxisTitle: "Number of Assets",
          showDataLabels: true
        )
      ),
    
    /*
        local!labels: index(
          local!datasubset.data,
          "Status",
          {}
        ),
        local!uniqueLabels: union(
          local!labels,
          cast(
            typeof(
              local!labels
            ),
            {}
          )
        )
    
     */ 
      /* fv!item.Status is not required as fv!item already contains Status only  */

    /* fv!item.Status is not required as fv!item already contains Status only  */

    Thanks

    Aditya

     

Reply
  • Hi,

    You use below code,

     

    {
      with(
        local!chartPagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: - 1,
          sort: a!sortInfo(
            field: "SubmittedDate",
            ascending: true
          )
        ),
        local!SubmittedDate: null,
        local!datasubset: a!queryEntity(
          entity: cons!NSARequest_Entity_Cons,
          query: a!query(
            aggregation: a!queryAggregation(
              aggregationColumns: {
                a!queryAggregationColumn(
                  field: "Status",
                  alias: "Status",
                  isGrouping: true
                ),
                a!queryAggregationColumn(
                  field: "SubmittedDate",
                  alias: "SubmittedDate",
                  isGrouping: true,
                  groupingFunction: "MONTH"
                ),
                a!queryAggregationColumn(
                  field: "Id",
                  aggregationFunction: "COUNT"
                )
              }
            ),
            pagingInfo: local!chartPagingInfo
          )
        ),
        local!Categories: index(
          local!datasubset.data,
          "SubmittedDate",
          {}
        ),
        local!uniqueCategories: union(
          local!Categories,cast(typeof(local!Categories),{})
        ),
        local!labels: index(
          local!datasubset.data,
          "Status",
          {}
        ),
        local!uniqueLabels: union(
          local!labels,
          cast(
            typeof(
              local!labels
            ),
            {}
          )
        ),
        local!series: a!forEach(
          local!uniquelabels,
          with(
           local!label: fv!item,
            a!chartSeries(
              label: local!label,
              data: a!forEach(
                local!uniqueCategories,
                with(local!intersection: intersection(
                    where(local!Categories = cast(typeof(local!Categories), fv!item),0),
                    where(local!labels = cast(typeof(local!labels),local!label), 0)
                  ),
                  if(condition: length( local!intersection) = 0,
                    valueIfTrue: 0,
                    valueIfFalse: index(index(local!datasubset.data,"Id",{}),local!intersection,0)
                  )
                )
              ),
              links: a!dynamicLink( saveInto: { a!save(ri!selectedStatus, fv!item)}  /* fv!item.Status is not required as fv!item already contains Status only  */
              )
            )
          )
        ),
        a!lineChartField(
          label: "Number of Assets per Month",
          categories: {
            {
              local!uniqueCategories
            }
          },
          series: local!series,
          xAxisTitle: "Month",
          yAxisTitle: "Number of Assets",
          showDataLabels: true
        )
      ),
    
    /*
        local!labels: index(
          local!datasubset.data,
          "Status",
          {}
        ),
        local!uniqueLabels: union(
          local!labels,
          cast(
            typeof(
              local!labels
            ),
            {}
          )
        )
    
     */ 
      /* fv!item.Status is not required as fv!item already contains Status only  */

    /* fv!item.Status is not required as fv!item already contains Status only  */

    Thanks

    Aditya

     

Children
No Data

 Discussion posts and replies are publicly visible