Hi All,
I am trying to sort the results of a table in arcade but having trouble hitting the table's fields. This table is related based on a pin, but not joined in any way to the feature set that the arcade expression is running on. It is arcade in ArcGIS Portal Popups.
Snippet below.
#assign table
var tbl = FeatureSetByName($map,"TABLE");
# assign pin
var pt = $feature['PIN'];
#create sql variable
var sql = "PIN = '" + pt + "'";
#run query on table
var query = Filter(tbl, sql);
var order = OrderBy(query, 'date DESC')
var result = ""
for (var field in order) {
result += ....;}
return result;
However when running this it tries to search the $feautre instead of the table resulting in field not found error.. Any asssitance would be appreacited.
Solved! Go to Solution.
Hi Cameron McArtney ,
Before looking at the code below, I have a question? What version of Enterprise do you have installed. This will define what functions are available to you. To be sure consult the version matrix: Version Matrix | ArcGIS for Developers
I have included a couple of Console statements to write to the console to see if you have any results and what you get on the way. Can you try this and post back the information printed to the console?
// assign table
var tbl = FeatureSetByName($map,"TABLE");
Console(Count(tbl));
// assign pin
var pt = $feature['PIN'];
Console(pt)
// create sql variable
var sql = "PIN = @pt";
Console(sql);
// run query on table
var query = Filter(tbl, sql);
// it is good to check if you have any results
var cnt = Count(query);
Console(cnt);
var result = "There are " + cnt + " Result(s):";
if (cnt > 0) {
// sort the featureset
var order = OrderBy(query, 'date DESC');
// construct the result
for (var feat in order) {
// change "YourFieldName" for your field name
result += TextFormatting.NewLine + feat.YourFieldName;
}
}
return result;
Hi Cameron McArtney ,
Before looking at the code below, I have a question? What version of Enterprise do you have installed. This will define what functions are available to you. To be sure consult the version matrix: Version Matrix | ArcGIS for Developers
I have included a couple of Console statements to write to the console to see if you have any results and what you get on the way. Can you try this and post back the information printed to the console?
// assign table
var tbl = FeatureSetByName($map,"TABLE");
Console(Count(tbl));
// assign pin
var pt = $feature['PIN'];
Console(pt)
// create sql variable
var sql = "PIN = @pt";
Console(sql);
// run query on table
var query = Filter(tbl, sql);
// it is good to check if you have any results
var cnt = Count(query);
Console(cnt);
var result = "There are " + cnt + " Result(s):";
if (cnt > 0) {
// sort the featureset
var order = OrderBy(query, 'date DESC');
// construct the result
for (var feat in order) {
// change "YourFieldName" for your field name
result += TextFormatting.NewLine + feat.YourFieldName;
}
}
return result;
Hi Xander Bakker,
You're spot on, it's version related, running 10.7.1, so ran a test in ArcGIS Online and it works.
I need to investigate further however if it is a bug or just missing in the version. As it fails as its trying to hit the $feature fields instead of the tables fields. Where as AGOL is able to hit the tables fields.
Cheers,