Hello, I have a set of points with unique identifiers (IDENT), and for each point, different treatments (TRMNT) were applied on different dates.
Here is the structure of my data:
I am trying to visualize all the information for each point, including the treatment and date, using the results of the FeatureSetByRelationshipName function. I found a solution on the Esri Community website in this post: "Displaying all information from a FeatureSetByRelationshipName."
I made some changes to the script as follows:
var relatedrecords = OrderBy(FeatureSetByRelationshipName($feature,"Invasive_Inspection_new"), "Date");
var cnt = Count(relatedrecords);
var relatedinfo = "";
if (cnt > 0) {
// use GroupBy to summarize the Date of all Treatment
var stats = GroupBy(relatedrecords, "Date", [
{ name: "count", expression: "Date", statistic: "COUNT" }
]);
var infos = GroupBy(relatedrecords, "TRMNT", [
{ name: "count", expression: "TRMNT", statistic: "COUNT" }
]);
// report the result
relatedinfo = "Treatment Date:"
for (var stat in stats) {
relatedinfo += "\n" + Text(ToLocal(stat.Date), "MM/Y")+ " (TRMNT: ";
for (var info in infos) {
relatedinfo += info.TRMNT +")" ;
}
}
} else {
relatedinfo = "No related information";
}
return relatedinfo;
Following the instructions provided in that post, I managed to display the dates successfully. However, I encountered an issue where the correct information for the treatments (TRMNT) is not displayed for each date. Instead, all treatments are being shown for each date. I attempted to solve this problem by implementing a loop to select the appropriate treatment information for each date, but unfortunately, it did not work.
The resulting pop-up display appears as follows:
Would you please help me?