I have created a scripted field to calculate the total based on items in an array in the document
int total= 0;
for(int i = 0; i < params._source['ServiceItemList'].size(); i++) {
total+= params._source['ServiceItemList'][i].Fee;
}
return total/100;
The document is something like this
{
"Patient":"John Doe",
"Clinic":"ACME",
"BillingType": "Private",
"ServiceItemList": [
{
"ItemNo": "5555",
"Fee": 10910,
"ShortDescription": "Ultrasound MSK"
},
{
"ItemNo": "1111",
"Fee": 8555,
"ShortDescription": "Consultation"
}
]
}
The scripted field works fine in the dashboards but doesn't work when I try on Canvas, It says unknown column.
Are scripted fields supported in canvas? if not is there another way I can draw a table with two columns Patient name and Total in canvas