Select to view content in your preferred language

Arcade code works in Test but not in the map

1601
3
03-02-2021 09:39 AM
Labels (1)
DougBrowning
MVP Esteemed Contributor

I have some Arcade code that is working in test mode but then does not work in the popup or attribute table.

Test works

DougBrowning_0-1614703055847.png

Popup is blank

DougBrowning_1-1614703085284.png

and attribute table gives a data error

DougBrowning_2-1614703166563.png

That means my code works but there is some other issue.  ArcPro does not like it either.

Here is the code.  I am trying to create a unique list across multiple fields and repeats from a 123 form.  It is also a select multiple so the data is 1,2,3,4 etc.  That makes the code pretty messy but it does work.

var sql = "SpeciesEvaluationID = '" + $feature.EvaluationID + "'";
var tbl = Filter(FeatureSetByName($map,"VegSpecies", ['*'], false), sql);
var speciesList = '';
var oneRow = [];
for (var species in tbl) {
    oneRow = Split(species.RightBankNoxiousCommonName, ',')
    for (var i in oneRow) {
        if (!IsEmpty(oneRow[i]) && Find(oneRow[i], speciesList) == -1) {
            speciesList += oneRow[i]  + ', ';
        }   
    }
    oneRow = Split(species.LeftBankNoxiousCommonName, ',')
    for (var i in oneRow) {
        if (!IsEmpty(oneRow[i]) && Find(oneRow[i], speciesList) == -1) {
            speciesList += oneRow[i]  + ', ';
        }   
    }

}
return speciesList

 

 

Open to any ideas.  Thanks

0 Kudos
3 Replies
JohannesLindner
MVP Frequent Contributor

I would start by making it a bit simpler:

var evalID = $feature.EvaluationID
var sql = "SpeciesEvaluationID = @evalID";  // automatically takes care of the right syntax
var tbl = Filter(FeatureSetByName($map, "VegSpecies", ['*'], false), sql);
var speciesList = [];  // Make this a list
var oneRow = [];
for (var species in tbl) {
    // Handle both attributes at the same time
    oneRow = Split(species.RightBankNoxiousCommonName + ',' + species.LeftBankNoxiousCommonName, ',');
    for (var i in oneRow) {
        speciesList[Count(speciesList)] = oneRow[i];  // Just append every found species
    }
}
return Concatenate(Distinct(speciesList), ', ')  // Extract unique species and concatenate

 

In ArcGIS Pro, both your code and my simplification work. Do you get an error message?


Have a great day!
Johannes
0 Kudos
DougBrowning
MVP Esteemed Contributor

After more testing it is kinda working in Pro.  It will not display on screen in a layout but when we run data driven pages it does work.

Also it is working in the pop up in Map Viewer Beta

DougBrowning_0-1614782024382.png

Map beta attribute table does not seem to show Arcade at all as an option - weird.

 

I then tried your code and same deal.  I had got rid of arrays just in case.  Works in Test but not the popup (blank) or table (data error) in regular map viewer.

My guess is that it is timing out or something.

Thanks

0 Kudos
DougBrowning
MVP Esteemed Contributor

I got another one today doing the same thing.  Works in Test and in Pro but not the popup or in the attribute table.

Seems like a timeout to me?

var evalID = $feature.EvaluationID
var sql = "HumanEvaluationID = @evalID";  // automatically takes care of the right syntax
var tbl = Filter(FeatureSetByName($map, "HumanInfluence", ['*'], false), sql);
var arrayIndex = 0
var humanList = []
for (var row in tbl) {
    if (row.RowCrops != "Absent") {
        humanList[arrayIndex] = "RowCrops"
        ++arrayIndex
    }
        if (row.PastureHayFence!="Absent") {
        humanList[arrayIndex] = "PastureHayFence"
        ++arrayIndex
    }
    if (row.InstreamRestoration!="Absent") {
        humanList[arrayIndex] = "InstreamRestoration"
        ++arrayIndex
    }
    if (row.LivestockHorseBurro!="Absent") {
        humanList[arrayIndex] = "LivestockHorseBurro"
        ++arrayIndex
    }
    if (row.Mining!="Absent") {
        humanList[arrayIndex] = "Mining"
        ++arrayIndex
    }
    if (row.Recreation!="Absent") {
        humanList[arrayIndex] = "Recreation"
        ++arrayIndex
    }
    if (row.LoggingOperations!="Absent") {
        humanList[arrayIndex] = "LoggingOperations"
        ++arrayIndex
    }
    if (row.WallDikeRipRap!="Absent") {
        humanList[arrayIndex] = "WallDikeRipRap"
        ++arrayIndex
    }
    if (row.BuildingsPowerlines!="Absent") {
        humanList[arrayIndex] = "BuildingsPowerlines"
        ++arrayIndex
    }
    if (row.PavementClearedLot!="Absent") {
        humanList[arrayIndex] = "PavementClearedLot"
        ++arrayIndex
    }
    if (row.RoadRailroadCulvert!="Absent") {
        humanList[arrayIndex] = "RoadRailroadCulvert"
        ++arrayIndex
    }
    if (row.Pipes!="Absent") {
        humanList[arrayIndex] = "Pipes"
        ++arrayIndex
    }
    if (row.HydrologicAlterations!="Absent") {
        humanList[arrayIndex] = "HydrologicAlterations"
        ++arrayIndex
    }
    if (row.LandfillTrash!="Absent") {
        humanList[arrayIndex] = "LandfillTrash"
        ++arrayIndex
    }
    if (row.ParksLawns!="Absent") {
        humanList[arrayIndex] = "ParksLawns"
        ++arrayIndex
    }
}
return Concatenate(Distinct(Sort(humanList)), ', ') 

 

 thanks

0 Kudos