Select to view content in your preferred language

Last date update return from layer

77
1
yesterday
Labels (1)
Piotrek6116
Emerging Contributor

Hello There,

I have an application, ExB, with one layer. I tried to type Arcade expression to return to me the last date update (printscreen)

 

layer from https://services6.arcgis.com or from the included layer from aplication.

I don't know how to type a formula.

My tried:
"Last date update: " + Text(Date($dataSources('dataSource_1')), "MM.DD.YYYY")

Where layer ID it's dataSource_1 but not works, for layer name too, what's is wrong?

Do you know how to return the date?

 
0 Kudos
1 Reply
KenBuja
MVP Esteemed Contributor

The section of the code "$dataSources('dataSource_1')" will give you the FeatureSet, but then you have to do some additional things to get the latest date. You would then have to sort the FeatureSet by the date field (line 2), get the first feature (line 3), then pass the attribute from the date field into the text expression (line 4). That would look something like this, if "yourField" is the name of the date field.

var fs = $dataSources("dataSource_1");
var sorted = OrderBy(fs, "yourField DESC");
var feat = First(sorted);
return "Last date update: " + Text(feat.yourField, "MM.DD.YYYY");
0 Kudos