Select to view content in your preferred language

Troubleshooting Arcade code

382
2
08-29-2024 01:25 PM
KenBuja
MVP Esteemed Contributor

I have a map where I've added an Arcade element to a popup. It works properly when I test in Map Viewer but when I try it in Field Maps, the app crashes and restarts. I've tried looking in the Troubleshooting log, but it only shows the information after the app restarts. In the attached log, I clicked the feature exactly at 4:00 pm and the first log entry is when it restarts several seconds later.

How can I determine what is causing the crash? This is the code I'm using

 

var fields = Schema(FeatureSetByPortalItem(Portal('url'), 'item')).fields;
var attributes = {};
var fieldInfos = [];

function fieldTest(fieldList, fieldName, fieldAlias) {
  if (Includes(fieldList, fieldAlias)) {
    attributes[fieldalias] = $feature[fieldName]
    Push(fieldInfos, { fieldName: fieldAlias });
  }
}

var code = DomainName($feature,"Survey");
for (var i in fields) {
  if (code == "Fish and Benthic") fieldTest(["Site ID","Fish Status","Fish Date","Benthic Status", "Benthic Date"], fields[i].name, fields[i].Alias);
  else fieldTest(["Site ID","Fish Status","Fish Date"], fields[i].name, fields[i].alias);

}

return { 
  type: "fields", 
  fieldInfos: fieldInfos, 
  attributes: attributes
}; 

 

0 Kudos
2 Replies
CodyPatterson
MVP Regular Contributor

Hey @KenBuja 

Long shot here, but if your variables are fieldAlias for your function, you have it as fieldalias in attributes[fieldalias], maybe changing it to fieldAlias instead may get you past this, otherwise I'm not seeing an issue from this.

Cody

0 Kudos
KenBuja
MVP Esteemed Contributor

Thanks for the response. Unfortunately, changing it to fieldAlias didn't make a difference.

0 Kudos