Hi all -
I am trying to build a dashboard list widget use a layer and a table join. I used the following expression and was able to get the data I wanted but I keep getting a "cannot access data" yellow triangle in the corner of the widget. All sharing is set to "everyone" with groups on. Has anyone else run into this issue before??
Portal and ID's have been removed.
// Dashboards Data Expression (DETAIL)
// FULL OUTER JOIN (robust)
// Key: Projects.REL_OBJECTID ↔ Citywide.REL_OBJECTID
var p = Portal("");
var projects = FeatureSetByPortalItem(
p, "", 0,
["REL_OBJECTID","CIPName","PWAType"], false
);
var citywide = FeatureSetByPortalItem(
p, "", 0,
["OBJECTID","REL_OBJECTID","CIPName","PWAType"], false
);
function k(v){ return Text(DefaultValue(v,"")); }
function s(v){ return Text(DefaultValue(v,"")); }
function pref(a,b){ return IIF(!IsEmpty(a), a, b); }
// Lookup: REL_OBJECTID -> {CIPName, PWAType} (simple values only)
var prjByRel = Dictionary();
for (var pr in projects) {
var kk = k(pr["REL_OBJECTID"]);
if (IsEmpty(kk)) continue;
prjByRel[kk] = {
CIPName: s(pr["CIPName"]),
PWAType: s(pr["PWAType"])
};
}
// Track Citywide keys so we can emit unmatched projects
var cwKeys = Dictionary();
for (var cw0 in citywide) {
var kk2 = k(cw0["REL_OBJECTID"]);
if (!IsEmpty(kk2)) cwKeys[kk2] = 1;
}
var features = [];
var oid = 1;
// 1) All Citywide rows
for (var cw in citywide) {
var relKey = k(cw["REL_OBJECTID"]);
var hasPrj = (!IsEmpty(relKey) && HasKey(prjByRel, relKey));
var prA = IIF(hasPrj, prjByRel[relKey], Null);
var cwName = s(cw["CIPName"]);
var cwType = s(cw["PWAType"]);
var prName = IIF(hasPrj, prA["CIPName"], "");
var prType = IIF(hasPrj, prA["PWAType"], "");
Push(features, { attributes: {
OID: oid,
REL_OBJECTID: DefaultValue(cw["REL_OBJECTID"], Null),
CitywideOID: DefaultValue(cw["OBJECTID"], Null),
CIPName: pref(cwName, prName),
PWAType: pref(cwType, prType),
HasProject: IIF(hasPrj, 1, 0),
HasCitywide: 1
}});
oid++;
}
// 2) Projects with no Citywide rows
for (var pr2 in projects) {
var relKey2 = k(pr2["REL_OBJECTID"]);
if (!IsEmpty(relKey2) && HasKey(cwKeys, relKey2)) continue;
Push(features, { attributes: {
OID: oid,
REL_OBJECTID: DefaultValue(pr2["REL_OBJECTID"], Null),
CitywideOID: Null,
CIPName: s(pr2["CIPName"]),
PWAType: s(pr2["PWAType"]),
HasProject: 1,
HasCitywide: 0
}});
oid++;
}
return FeatureSet({
fields: [
{ name:"OID", type:"esriFieldTypeOID" },
{ name:"REL_OBJECTID", type:"esriFieldTypeInteger" },
{ name:"CitywideOID", type:"esriFieldTypeInteger" },
{ name:"CIPName", type:"esriFieldTypeString" },
{ name:"PWAType", type:"esriFieldTypeString" },
{ name:"HasProject", type:"esriFieldTypeInteger" },
{ name:"HasCitywide", type:"esriFieldTypeInteger" }
],
geometryType: "",
features: features
});