merging multiples layers in a unique list widget with arcade

160
0
11-10-2021 02:16 AM
DISIG
by
New Contributor III

Hello everybody,

For a dashboard i would like to merge two layers with arcade data expression to display the result in a unique list widget (i have to minimize the number of widgets and clicks to keep my users aware...)

i tried to adapt the code from the arcade git. but i don't know if it really could work in a list widget.

any ideas?

here is the code : 

var portal = Portal("https://www.arcgis.com/"); 
var notations = FeatureSetByPortalItem(portal,"9abab4147fbb4d708c7058e4269b12f7",0,['RD','TXT_ANNEE','NOTE','CumulD','CumulF','OBJECTID'],false) 
var travaux = FeatureSetByPortalItem(portal,"162565e07fc745ae94dbb33fafed250a",0,['RD','TXT_ANNEE','NATURE','CUMULD','CUMULF','OBJECTID'],false) 
var i = 0; 
 var combinedDict = { 
    fields:[ 
        {name : "identifiant",type : "esriFieldTypeInteger"}, 
        {name : "source",type : "esriFieldTypeString"}, 
        {name : "rd",type :"esriFieldTypeString"}, 
        {name : "legende",type :"esriFieldTypeString"}, 
        {name : "annee",type :"esriFieldTypeString"}, 
        {name : "CumulD",type :"esriFieldTypeString"}, 
        {name : "CumulF",type :"esriFieldTypeString"}, 
    ], 

    geometryType:"", 
   features:[], 
}; 

for (var n in notations){ 
    combinedDict.features[i] = { 
        attributes: { 
            identifiant : ["OBJECTID"], 
            source : "notation", 
            rd : n["RD"], 
            legende : n["NOTE"], 
            annee : n["TXT_ANNEE"], 
            CumulD : n["CumulD"], 
            CumulF : n["CumulF"], 
        }, 
    }; 
    i++; 
}    
for (var n in travaux){ 
    combinedDict.features[i] = { 
        attributes: { 
            identifiant : ["OBJECTID"], 
            source : "travaux", 
            rd : n["RD"], 
            legende : n["NATURE"], 
            annee : n["TXT_ANNEE"], 
            CumulD : n["CUMULD"], 
            CumulF : n["CUMULF"], 
        }, 
    }; 
    i++; 
} 
return FeatureSet(Text(combinedDict)); 
0 Kudos
0 Replies