Select to view content in your preferred language

Arcade: FeatureSet - How to reference a standalone table?

631
4
10-31-2023 08:29 AM
ArmstKP
Frequent Contributor

Since one can't reference a standalone table with FeatureSetByName, like I have in line 2 below, what are my other options for Field Maps?

var plowhistory = Intersects(FeatureSetByName($map,"HistoryPlowingStatusParkingLots VIEW"), $feature);
var eventhistory = FeatureSetByName($map, "Events_view", ['eventstart'],false);

var eventhistorySorted = OrderBy(eventhistory, 'eventstart DSC')
var firsteventhistorySorted = First(eventhistorySorted)

var sql = "lastserviced > '"+firsteventhistorySorted.eventstart+"'"
var filterhistory = Filter(plowhistory, sql);
var filterhistorySort = Orderby(filterhistory, 'lastserviced DESC')
var popupString = "";

for (var myfeature in filterhistorySort){
    popupString += text(myfeature.lastserviced, 'MMM DD Y, hh:mm A') + '  ' + '|' + ' ' + ' ' + myfeature.vehicleid + ' | ' + ' ' + myfeature.makemodel +
    TextFormatting.NewLine 
}
return popupString

 

0 Kudos
4 Replies
jcarlson
MVP Esteemed Contributor

There's FeatureSetByPortalItem. But do you need it to work offline for Field Maps? I feel like I've used FeatureSetByName to grab hosted tables as well, but then, they're usually in the same service, so $datastore works.

Any chance there's a relationship class in place?

- Josh Carlson
Kendall County GIS
0 Kudos
ArmstKP
Frequent Contributor

@jcarlson I don't need it offline and there is no relationship.

0 Kudos
ArmstKP
Frequent Contributor

@jcarlson The below works in the map viewer, but not in Field Maps:

var plowhistory = Intersects(FeatureSetByName($map,"HistoryPlowingStatusParkingLots VIEW"), $feature);
var eventhistory = FeatureSetByPortalItem(Portal('https://www.arcgis.com'),"623275cbca4a485780e375e2ba4f1c5e", 1, ['eventstart'],false);

var eventhistorySorted = OrderBy(eventhistory, 'eventstart DSC')
var firsteventhistorySorted = First(eventhistorySorted)

var sql = "lastserviced > '"+firsteventhistorySorted.eventstart+"'"
var filterhistory = Filter(plowhistory, sql);
var filterhistorySort = Orderby(filterhistory, 'lastserviced DESC')
var popupString = "";

for (var myfeature in filterhistorySort){
    popupString += text(myfeature.lastserviced, 'MMM DD Y, hh:mm A') + '  ' + '|' + ' ' + ' ' + myfeature.vehicleid + ' | ' + ' ' + myfeature.makemodel +
    TextFormatting.NewLine 
}
return popupString
0 Kudos
ArmstKP
Frequent Contributor

@jcarlson Actually, it looks like the Filter function in lines 8 and 7 might be causing the issue in Field Maps....

0 Kudos