Interface filter based on process start time does not work. Error : Invalid index: Cannot index property of type Text into type List of Variant

I have a process backed record with filters based on process start time. Filters work fine in records but when i have it in interface, it throws error except for "Any time". Error is below.

Interface Definition: Expression evaluation error at function 'index' parameter 3 [line 55]: Invalid index: Cannot index property 'MilestoneSchedule' of type Text into type List of Variant

Code snippet is below:

load(
local!daysFilterLabels: { "Any Time", "Last 24 Hours", "Last 7 Days", "Last 30 Days","Last 365 Days" },
local!daysFilterValues: {-1,0,1,2,3},
local!selectedDaysFilter: -1,
local!showprocesstime: -1,
local!pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 20,
sort: a!sortInfo(
field: "pp.startTime",
descending: true
)
),
with(
local!datasubset: queryrecord(
cons!MP_MY_ACTIVE_MILESTONE_SCHEDULES_RECORD,
a!query(
selection: a!querySelection(columns: {
a!queryColumn(field: "MilestoneSchedule.ReqNumber"),
a!queryColumn(field: "MilestoneSchedule.RFPNumber"),
a!queryColumn(field: "MilestoneSchedule.AwardType"),
a!queryColumn(field: "MilestoneSchedule.ProgramOffice"),
a!queryColumn(field: "MilestoneSchedule.ContractingOfficer"),
a!queryColumn(field: "MilestoneSchedule.ProjMSStartDate"),
a!queryColumn(field: "MilestoneSchedule.ProjMSEndDate"),
a!queryColumn(field: "MilestoneSchedule.ActMSStartDate"),
a!queryColumn(field: "MilestoneSchedule.Title"),
a!queryColumn(field: "pp.startTime"),
}),
filter: /*if(local!selectedDaysFilter=-1,null,null),*/
if(local!selectedDaysFilter=-1,null,
if(local!selectedDaysFilter=0,a!queryFilter(field: "pp.startTime", operator: ">=", value: fn!todatetime(fn!today()-1)),
if(local!selectedDaysFilter=1,a!queryFilter(field: "pp.startTime", operator: ">=", value: fn!todatetime(fn!today()-7)),
if(local!selectedDaysFilter=2,a!queryFilter(field: "pp.startTime", operator: ">=", value: fn!todatetime(fn!today()-30)),
if(local!selectedDaysFilter=3,a!queryFilter(field: "pp.startTime", operator: ">=", value: fn!todatetime(fn!today()-365)),null))))
),
pagingInfo: local!pagingInfo
)
),

a!sectionLayout(
contents:{
a!dropdownField(
label:"Started",
choiceLabels: local!daysFilterLabels,
choiceValues: local!daysFilterValues,
value: local!selectedDaysFilter,
saveInto: local!selectedDaysFilter
),
a!gridField(
totalCount: local!datasubset.totalCount,
columns: {
a!gridTextColumn(
label: "PR Number",
field: "MilestoneSchedule.ReqNumber",
data: index(local!datasubset.data.MilestoneSchedule, "ReqNumber", null),
links: a!forEach(
items: local!datasubset,
expression: rule!MP_GenerateProcessDashboardLInk(fv!identifier)
)
),

...................

  Discussion posts and replies are publicly visible

Parents
  • That error typically means that you are attempting to find a field in the query result that doesn't exist. In this case, it's saying that the field "MilestoneSchedule" doesn't exist in the result local!datasubset.data so Appian can't index it using the dot notation.

    The best way to approach this is to use multiple indexes to verify that each field exists. There are two ways to set up this index().

    1. One way is to just call the index function multiple times. In row 55 in your expression above, you could do that like this:

      index(
          index(
              local!datasubset.data,
              "MilestoneSchedule",
              {}
          ),
          "ReqNumber",
          {}
      )
    2. Another way to do it is to use the reduce function like this:

      reduce(
          fn!index,
          local!datasubset.data,
          {"MilestoneSchedule", "ReqNumber"},
          {}
      )

    Lastly, you may also want to investigate your query. Both the examples I gave above will solve the error message (that the "MilestoneSchedule" cannot be found), but it will simply display a blank grid. You may want to test your query with your various filters in a separate expression rule to make sure the correct values are returned.

  • Thanks Peter. Your 1st solution(multiple index) did the magic. Thanks again for your help!

Reply Children
No Data