Dashboard suddenly "unable to execute Arcade script" after the weekend

703
1
Jump to solution
07-24-2023 09:54 AM
Labels (2)
EmmaHatcher
Occasional Contributor

I have an Arcade script combining features from multiple feature classes between two Portals (which is what the Prod vs. QA refers to) to chart summaries of the data. All last week, the Dashboards were loading for me, but not for the end-user, who is the ended audience for this solution. This week, her issue has been passed onto me as well, which is great since I can now reproduce the issue, but not great because my troubleshooting is leading to a dead-end.

Last week, the data expression was successfully combining the feature classes and returning a Feature Set that I could chart in one place as pictured:

EmmaHatcher_1-1690217040268.png

 

This morning, when I loaded the app, all charts that have an expression pulling from the external Portal site returns data source errors:

EmmaHatcher_0-1690216850624.png

 


var portal = Portal("https://org.maps.arcgis.com")

var fcLst = [
  "Major Structures", 
  "Buried Structures", 
  "Utilities",
  "Culvert",
  "Drainage Line",
  "Drainage Point",
  "Drainage Polygon", 
  "Earthworks",
  "Fence",
  "Gate",
  "Pavement",
  "Wall"
  ]
  
var fcDict = {
  "0": "Major Structures Point", 
  "2": "Buried Structures", 
  "3": "Utilities",
  "4": "Culvert",
  "5": "Drainage Line",
  "6": "Drainage Point",
  "7": "Drainage Polygon", 
  "8": "Earthworks",
  "9": "Fence",
  "10": "Gate",
  "11": "Pavement",
  "12": "Wall"
};

var idx = 0
var fsId = "<item_id>";
var prodfsId = "<item_id_for_external_portal_item_added_to_the_same_organization_portal>";

var features = [];
var feat;
var count_lst = [];

for (var fc in fcLst) {
//There used to be a feature layer with ID 1 that was retired & no longer exists. Skip feature layer id = 1
  if (idx != 1) {
    var fcName = fcDict[Text(idx)];
    var lyr = FeatureSetByPortalItem(portal, fsId, idx);
    var prodLyr = FeatureSetByPortalItem(portal, prodfsId, idx);
    var empty = IsEmpty(lyr);
    if (empty != false){
      return null
   }
  else{
      var ftSetGrouped = GroupBy(lyr, 
      [
        {name: 'CP', expression: 'CP'},
        //{name: 'Asset_ClassPath', expression: 'Asset_ClassPath'}
      ],
      [
        { name: 'TotalCount', expression:"1", statistic: "COUNT"}
      ]
    );

    var prdSetGrouped = GroupBy(prodLyr,
    [
      {name: 'CP', expression: 'CP'},
    ],
    [
      { name: 'TotalCount', expression:"1", statistic: "COUNT"}
    ]
    );
	
    for (var f in ftSetGrouped){
        //return f
        feat = {
          'attributes':{
            'CP': f['CP'],
            'environment': "QA",
            'Feature_Class': fcName,
            'count': f['TotalCount']
          },
        };
        Push(features, feat);
      }

    for (var f in prdSetGrouped){
        //return f
        feat = {
          'attributes':{
            'CP': f['CP'],
            'environment': "Prod",
            'Feature_Class': fcName,
            'count': f['TotalCount']
          },
        };
        Push(features, feat);
      }
  }
  idx++
};

var combinedFts = {
   fields: [
     { name: 'CP', type: "esriFieldTypeString"},
     { name: 'environment', type: "esriFieldTypeString"},
     { name: 'Feature_Class', type: "esriFieldTypeString"},
     { name: 'count', type: "esriFieldTypeInteger"}
     ],
  geometryType: "",
  features: features
 };

return FeatureSet(Text(combinedFts))

 

What's even more curious is that the web map that displays both feature services in the same dashboard is loading all of the data just fine. The outage appears to only apply to the data expression. Does anyone have ideas about potential issues?

One maybe problem is that last week, the Dashboard would prompt the user to sign into the external portal site, which makes sense to ensure the user accessing the dashboard has the correct permissions for the external data, but that isn't happening this week.

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

Hard to know from the outside, but I would recommend adding some Console statements to your expression and then testing it, to see if there's a particular point of failure in the expression, or if it's a certain feature that is failing.

Since it worked, but now doesn't, it sounds more likely to be the latter. You write the expression based on the data you have and it works, then new data is added that you didn't account for, and the expression doesn't know what to do with it.

- Josh Carlson
Kendall County GIS

View solution in original post

1 Reply
jcarlson
MVP Esteemed Contributor

Hard to know from the outside, but I would recommend adding some Console statements to your expression and then testing it, to see if there's a particular point of failure in the expression, or if it's a certain feature that is failing.

Since it worked, but now doesn't, it sounds more likely to be the latter. You write the expression based on the data you have and it works, then new data is added that you didn't account for, and the expression doesn't know what to do with it.

- Josh Carlson
Kendall County GIS