Select to view content in your preferred language

Related Records in Dashboard Data Expression

865
1
07-02-2021 10:47 AM
Labels (1)
CANC-AndrewJohnsonGISS
Emerging Contributor

Hello,

I am working to build a data expression that pulls an attribute from a related table. I am not seeing any global variables : 

CANCAndrewJohnsonGISS_0-1625247312793.png

 

And when I filter to create a new featureset object, I cannot access its attributes within a for loop like I can when I use the unfiltered feature sets. Does anyone have some example code of this process?

 

// Write an expression that returns a FeatureSet.
// Documentation: https://arcg.is/3c419TD

//var plots = FeatureSetByPortalItem(Portal('https://geoplatform.maps.arcgis.com'), '88cf338d4ace40c099fe17fdab889537', '0')
var Char = FeatureSetByPortalItem(Portal('https://geoplatform.maps.arcgis.com'), '88cf338d4ace40c099fe17fdab889537', '5')
var SoilPit = FeatureSetByPortalItem(Portal('https://geoplatform.maps.arcgis.com'), '88cf338d4ace40c099fe17fdab889537', '15')
Console(Char)
var choicesDict = {
    fields:[
        { name: "SoilKey", type: "esriFieldTypeString" },
        { name: "Texture", type: "esriFieldTypeString" },
        { name: "HorizonKey", type: "esriFieldTypeString" },
        { name: "Office", type: "esriFieldTypeString" },
    ],
    'geometryType': '',
    'features':[]
};
var i = 0;

for (var feature in SoilPit){
    var Soil_Key = feature["SoilKey"]
    Console(Soil_Key)
    var filter_query = "PrimaryKey" + " ='" + Soil_Key + "'";
    Console("filter query",filter_query)
    var officeFS = Filter(Char,filter_query)
    
    Console(officeFS)
    for (var f in officeFS){
        choicesDict.features[i] = {
        attributes: {
        SoilKey: feature["SoilKey"],
        Texture: feature["Texture"],
        HorizonKey: feature["HorizonKey"],
        Office: f.Office,
        },
      };
      i++;    
        
    }
    
    
}

return FeatureSet(Text(choicesDict))

 

 

0 Kudos
1 Reply
RobertBorchert
Honored Contributor

Create a VIEW instead 

0 Kudos