Select to view content in your preferred language

Data Expression unable to run Arcade Script Error

139
2
Jump to solution
3 weeks ago
JaronJensen7
New Contributor III

I have a dashboard where I am inserting an indicator. My indicator is looking at a layer and is working fine. I want to edit my reference layer to combine some data from two different layers. I am using the data expression option to create some arcade code to return the value that I want. I have gotten it to work in the arcade editor, but when I save the code and try to make it my reference layer it says "Unable to execute Arcade Script." 

The layers that I am trying to reference are part of a layer group. But it seems to work fine when it is in the editor and grabs the right data.

Any ideas on what I can try?

JaronJensen7_1-1716481128272.png

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

A Data Expression needs to return a FeatureSet, not a variable. Replace line 11 with this

var theDict = { 
  'fields': [{ 'name': 'result', 'type': 'esriFieldTypeInteger'}], 
  'geometryType': '', 
  'features': [
    { 
      'attributes': { 
        'result': Text(Round(fiber_total),'#,####')
      }
    }
  ]
}; 

return FeatureSet(theDict); 

View solution in original post

0 Kudos
2 Replies
KenBuja
MVP Esteemed Contributor

A Data Expression needs to return a FeatureSet, not a variable. Replace line 11 with this

var theDict = { 
  'fields': [{ 'name': 'result', 'type': 'esriFieldTypeInteger'}], 
  'geometryType': '', 
  'features': [
    { 
      'attributes': { 
        'result': Text(Round(fiber_total),'#,####')
      }
    }
  ]
}; 

return FeatureSet(theDict); 
0 Kudos
JaronJensen7
New Contributor III

@KenBuja Thank you that worked! I did have to get rid of the Text() function cause it seemed to be returning the number of characters. Once I did that it did give me my value that I wanted!

0 Kudos