Skip to main content
moulikad5353
June 13, 2023
Question

Invalid index: Cannot index property 'asDate' of type Text into null value of type. How to solve that?

  • June 13, 2023
  • 10 replies
  • 0 views

a!localVariables(
local!data: a!localVariables(
local!dateList: todate(
union(
index(ri!taskProductionList, "asDate"),
index(ri!taskProductionList, "asDate")
)
),
a!forEach(
local!dateList,
a!localVariables(
local!dateData: index(
ri!taskProductionList,
wherecontains(
fv!item,
todate(
index(ri!taskProductionList, "asDate", {})
)
),
{}
),
local!taskProduction: if(
and(rule!INO_isBlank(local!dateData)),
"-",
(
(
todecimal(local!dateData.taskId) / todecimal(local!dateData.taskDuration)
) * 100
),

),
if(
rule!INO_isBlank(local!dateData),
{
taskId: 0,
taskProduction: 0,
taskName: "-",
asDate: "-"
},
{
asDate: fv!item,
taskId: if(rule!INO_isBlank(local!dateData.taskId),0,local!dateData.taskId),
taskName: if(rule!INO_isBlank(local!dateData.taskName),0,local!dateData.taskName),
taskProduction: local!taskProduction,

}
)
)
)
),
{
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: a!richTextItem(
text: "Selected Task: " & ri!selectedGroup,
size: "MEDIUM",
color: "SECONDARY"
)
),
a!richTextDisplayField(
labelPosition: "COLLAPSED",
value: {
a!richTextIcon(
icon: "arrow-circle-left",
color: "ACCENT",
link: a!dynamicLink(value: null, saveInto: ri!selectedGroup),
linkStyle: "STANDALONE"
),
a!richTextItem(
text: " Back",
color: "ACCENT",
link: a!dynamicLink(value: null, saveInto: ri!selectedGroup),
linkStyle: "STANDALONE"
),

}
),
a!gridField(
labelPosition: "COLLAPSED",
borderStyle: "LIGHT",
initialSorts: { a!sortInfo(field: "asDate") },
data: local!data,
columns: {
a!gridColumn(
label: "Event Date",
sortField: "asDate",
value: a!richTextDisplayField(
value: a!richTextItem(text: fv!row.asDate)
)
),
a!gridColumn(
label: "Count of Tasks",
sortField: "taskId",
align: "END",
value: fv!row.taskId
),
/*a!gridColumn(
label: "Production Rate (tasks/hour)",
sortField: "taskProduction",
align: "END",
value: fixed(fv!row.taskProduction, 2, true)
)*/
}
),
/*a!textField(value:ri!taskProductionList ),
a!textField(value: todate(
union(
index(ri!taskProductionList, "asDate"),
index(ri!taskProductionList, "asDate")
)
) )*/
}
)

    10 replies

    June 13, 2023

    moulikad5353
    June 13, 2023

    how to fix the "asDate"

    mikes0011
    Brainy
    June 13, 2023

    What Sanchit is saying, is that you should edit your original post and insert your code into a Code Box, instead of pasting it plaintext - it's nearly unreadable in its current state.

    The Expression Guru
    harshitb6843
    June 13, 2023

    Why don't you have a 3rd parameter in your index() function?

    moulikad5353
    June 13, 2023

    3rd parameter is a default and it's not required all time. Could you plz tell me why this error occurred?

    mikes0011
    Brainy
    June 13, 2023

    The error message indicates you're attempting to access the property of a CDT or Dictionary when the property does not currently exist in that name in that instance of the dictionary or CDT.  For a Rule Input of "list of CDT" type, this is usually seen in the interface editor when the "test" value is loaded with a NULL value - i suspect if you try setting it as an empty set {}, it might work.

    Also, as Harshit mentioned, you should be using a 3rd parameter in your index() function (and IMHO you should be using property() when getting a property, and use index() when you're getting the index of an array, though that isn't what's making the difference here).  Using the "default" parameter allows the code to at least work otherwise when it encounters a missing property, and you can continue debugging from there.

    The Expression Guru