Select to view content in your preferred language

result of Arcade expression is showing object object in column

3777
10
Jump to solution
01-02-2023 02:07 AM
spiderman90
Emerging Contributor

 

Hello ,

i have used the iexpression here but i changed only the attributes name as my data and it works when i click on test ,i got the result that i want 

https://github.com/Esri/arcade-expressions/blob/master/dashboard_data/JoinLayerFieldsToTable.md

but after i added that expression to my table ,when i check the table of the layer in map viewer classic , it has automatically added the new attribute  as i want  but  it is showing object object in column.

i would like to show only the result  values from the expression  that i have brought from other table . 

 

 

Thanks in advance

Tags (1)
0 Kudos
10 Replies
CarmelConnolly
Esri Regular Contributor

Hi @Sergio , 

The main thing I notice is that the Push() function doesn't exist in Enteprise 10.8.1. If you look in the Functions list, it won't be there. Push() was introduced in Dec 2020 and tracing back it first appears in Enterprise 10.9. 

Instead add to your array using an older method (lines 3, 20, 21 introduced): 

// Create empty features array and feat object
var features = [];
var featuresIndex = 0;
var feat;
 
// Populate Feature Array
for (var t in tablefs) {
    var tableID = t["FeatureID"]
    for (var p in Filter(polyfs, "HydroID = "+tableID)){
        feat = {
            attributes: {
                FeatureID: tableID,
                Name: p["DPS_Region"],
ModelID: t["ModelID"],
                AddressCount: t["AddressCount"],
                MAX_TSTime: t["MAX_TSTime"],
            }
        }
 
    features[featureIndex] = feat;
    featureIndex++
    }
}

 

It's a little difficult without seeing your data, but for displaying one to many, I think the code needs to look like:

var keyField = $feature.keyField;
var polyfs = FeatureSetByName($map,"FC_polyfs");
var tablefs = Filter(FeatureSetByName($map,"T_tablefs - T_tablefs"), "keyField = " + keyField);

// Create empty features array and feat object
var features = [];
var featuresIndex = 0;
var feat;
 
// Populate Feature Array
for (var t in tablefs) {
    var tableID = t["FeatureID"]
    feat = {
        attributes: {
            FeatureID: tableID,
            Name: $feature["DPS_Region"],
            ModelID: t["ModelID"],
            AddressCount: t["AddressCount"],
            MAX_TSTime: t["MAX_TSTime"],
        }
    }
 
    features[featuresIndex] = feat;
    featuresIndex++
    }
}
 
var joinedDict = {
    fields: [
        { name: "FeatureID", type: "esriFieldTypeString" },
        { name: "Name", type: "esriFieldTypeString" },
        { name: "ModelID", type: "esriFieldTypeInteger" },
        { name: "AddressCount", type: "esriFieldTypeInteger" },
        { name: "MAX_TSTime", type: "esriFieldTypeString" },
    ],
    'geometryType': '',
    'features':features
};
 
// Return dictionary cast as a feature set 
return FeatureSet(Text(joinedDict));

 

So instead of looking through every table row, you're looping through every table row that has the polygon's matching 'keyField' (swap this for your matching field name).

 

0 Kudos