Select to view content in your preferred language

Arcade Data Expressions in ArcGIS Dashboards in Portal

1668
4
Jump to solution
09-27-2023 02:43 PM
GISUser74305830
Regular Contributor

I've used Data Expressions in dashboards in AGO quite a bit in the past, but I'm not certain how to do so in Portal. We use Windows Authentication to login to Portal, but I can't figure out how to use the FeatureSetByPortalItem function to return the item without having to pass in credentials. I would like to just reference the Portal URL, then the item id, then have it return the feature. How do you work with data expressions in Portal?

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

A Data Expression needs to return a FeatureSet, and that's the only thing a widget knows how to work with. I'm sure it actually does execute, but since the result is a single number, the dashboard just starts waving its hands.

Wrap the output in a FeatureSet like this:

return FeatureSet(Text({
  fields: [{name: 'the_total', type: 'esriFieldTypeInteger'}],
  geometryType: '',
  features: [{attributes:{the_total:Structure_Total}}]
}))

 

- Josh Carlson
Kendall County GIS

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

You can find a whole host of examples here: https://github.com/Esri/arcade-expressions/tree/master/dashboard_data

Using Data Expressions in Portal is the same as AGOL, except that the types of functions available to you will depend on your Portal version.

As far as credentials, that really depends on where your expression runs and where the data layer is. If you're trying to access a protected layer, you'll need to be authenticated. If your expression was running in a Dashboard in your Portal, then you probably already are, and it won't prompt you. But if the expression ran in AGOL and you were loading a Portal layer, that's when it requires authentication, and sounds like what you're experiencing.

Any reason why your dashboard and data layer are in different portals, if that is the case?

- Josh Carlson
Kendall County GIS
0 Kudos
GISUser74305830
Regular Contributor

Everything is in Portal and the user has to sign in to view the dashboard. So that's nice and simple.

 

But the weird thing is when I test the script in the Arcade dialog it outputs the result, but when I try to use it in the indicator it says "Unable to execute Arcade script". See below.

0 Kudos
jcarlson
MVP Esteemed Contributor

A Data Expression needs to return a FeatureSet, and that's the only thing a widget knows how to work with. I'm sure it actually does execute, but since the result is a single number, the dashboard just starts waving its hands.

Wrap the output in a FeatureSet like this:

return FeatureSet(Text({
  fields: [{name: 'the_total', type: 'esriFieldTypeInteger'}],
  geometryType: '',
  features: [{attributes:{the_total:Structure_Total}}]
}))

 

- Josh Carlson
Kendall County GIS
GISUser74305830
Regular Contributor

I'll be damned! that works! 

 

I skipped over the whole "must return a FeatureSet". I've been able to work quite a bit with Arcade in dashboards and popups without necessarily maintaining a comprehensive understanding of Globals and all that stuff, which is why the "return a FeatureSet" didn't sear into my brain. 

 

Thank you Josh!