Feature Info Widget - Sort by Date

142
1
07-12-2021 11:16 PM
Labels (1)
JonathanMcDougall
Occasional Contributor III

I've a related table showing inspections, I want the user to be able to see the latest inspection first in a pop-up Feature Info window. Why on earth, regardless of the sorting order, does it either give me the last record or first but will always pick the oldest?

Just to clarify, a feature with 16 inspections so far this year - the inspection table data, in feature info, is to sort by date descending. Selecting the asset, the feature info will give me record 16 of 16, which is the eldest on sort descending, 1 of 16 if sorting data ascending. You'd think it'd be easy to return 1 of 16 with descending.

I've no other sorting applied to the dataset within Data.

Is there an easy way to assure I get record 1, latest?

0 Kudos
1 Reply
JessicaRamirez1
New Contributor II

Hi, I had the same issue. I used an arcade expression in the pop-up to return the the most current record. 

I hope this helps.

var relatedrecords = OrderBy(FeatureSetByRelationshipName($feature,"ServiceCycleRecords", ['Monday_1'], false), 'Effective_Date DESC');
var cnt = Count(relatedrecords);
var info = "";$feature
if (cnt > 0) {
info = First(relatedrecords);
info = info.Monday_1
}
return info;

0 Kudos