Arcade FeatureSet Function to Display Related Data in Attribute Table...Not Working as Expected

6555
11
07-22-2020 03:30 PM
BrantCarman
Occasional Contributor

Hi,

I'm using FeatureSetByID in an arcade expression to display attribute data from a related layer in my pop-ups and in the attribute table.  The pop-up functionality is working great, but I'm running into some issues with getting the related attributes to display in the attribute table in web map viewer, as well as in the attribute table widget in Web AppBuilder.

In order to view the attributes in the attribute table in web map viewer, you are required to click "Show" for each and every attribute, which obviously is not ideal when you have thousands of records.  See first Screenshot.

When I view the attribute table in Web AppBuilder, I instead see "[object Promise]" where my related attributes should display.  See second screenshot.

I'm wondering if I might be missing something in my arcade expression that would fix both of these issues.  Any assistance or input would be greatly appreciated.

Thank you!

PS, Here is a sample of the function I'm using to return related attributes:

   var relatedSite = FeatureSetById($datastore, /* Visual and Sample Survey Collections (Current) */ "0")

   var observNum = $feature["observation_number"]

   var badData = "Bad Data - Delete"

   var filterStatement = "observation_number = @observNum AND trap_status <> @badData"

   var hostFromSite = First(Filter(relatedSite,filterStatement))

   return hostFromSite.trap_type

11 Replies
BrittanyBurson
Occasional Contributor III

Hi -- like you, we've had success displaying these Arcade attributes in the pop-ups, but their use seems to end there. I have the same experience as you, where you must click Show to calculate it in the web map attribute table, and see only  "[object Promise]" in Web App builder. We'd love to be able to view them in the attribute table or even better, have them export to csv as part of the layer.
I asked about this during the UC last week where it was suggested to instead apply these as Arcade-driven Field Calculations on the feature layer itself (Feature layer > Data tab > click on a field, "Calculate" > Arcade or SQL), which will go through and calculate the value for the entire dataset at once rather than on-the-fly via a click in the map. This works even for functions like Intersect or Within, even though they're not together as layers in a map. Concerns with that are scheduling it to update periodically, and not being a viable option for very large datasets.

So I'm here to see other replies and suggestions. Thanks!

BillyHopper
New Contributor III

I am experiencing the same issue in a web app that I am trying to deploy as a proof of concept for my agency.  

I get the FeatureSetByID to work in the popup which is fantastic, but I am trying to implement it using the Public Notification widget, and when I try to create a mailer using the widget, all of the columns that I have created return [object Promise] instead of the value itself.  

Looking it up online, it seems that the code needs to include a "then" statement in order for this function to work all the way through into the end result.  Hopefully ESRI folks will see this and give this awesome functionality to us?

In my example we have parcels (about 400,000 throughout our jurisdiction) and we have a separate table of owner data with a common field "APN".  I want to be able to quickly and easily provide a frontend for our users that will allow searching spatially for one or many parcels, then return the owner data so they can make contact as appropriate for notification purposes.  

The data is a referenced dataset, not hosted feature layer, I have thought of creating a view as Brittany suggests except that I need it updated dynamically, not just a one time calculate.  

Thank you all for the awesome help you always provide!

Regards,

Billy

PhilippeVDV
New Contributor III

Hi

 

I run into exactly the same issue. We collect data through Survey123 where field technicians are doing inspections along pipelines. The hosted feature layer that stores the information has 2 layers, one that stores information about the inspection itself (ID of the pipeline, name of the company that executed the inspection, ...) and a second layer that collects info about the incidents along the pipeline. There's a 1 to many relationship between the inspection layer and the incidents layer. For the incidents layer (child), I would like to join the attributes from the inspection layer (parent).

Works fine through the following script:

var ID = $feature.parentrowid;
var parent = FeatureSetByName($datastore,"Inspection");
var sql = "uniquerowid = '" + ID + "'";
Console(sql);
var related_data = First(Filter(parent, sql));
return related_data.company

 

The name of the company that executed the inspection shows up in the pop-ups of the incident layer which is nice!

However, in the attribute table in map viewer we see a hyperlink 'Show' for every single attribute. And in a web app built with Web AppBuilder we see [object Promise] as an attribute value.

@XanderBakker , do you have any thoughts on this? A calculate field (as suggested above) is not a good workaround, it should be something more dynamically

 

Thanks in advance!

Philippe

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @PhilippeVDV ,

There is a big difference between the impact of an Arcade expression when called from a pop-up (it will be executed once) and from the attribute table. In an attribute table, there can be potentially thousands of records and each record would trigger the execution of the Arcade expression. This would have a huge impact on performance. Therefore, you will see a link that will execute a single expression to avoid this. The same you will experience in WAB. 

Can you explain a little bit about what experience you want to provide to the end-user?

0 Kudos
PhilippeVDV
New Contributor III

Hi @XanderBakker 

Thanks a lot for your reply!

I follow your reasoning. However, there is a difference in behavior between a web map in map viewer and a web app in Web Appbuilder. In the map viewer,  you'll see the 'Show' hyperlink in the attribute table which allows to execute the Arcade script just once for a certain feature. However, in Web Appbuilder, you only see errors in the attribute table : [Object Promise]. Please compare screenshots 1 & 2 that were attached by @BrantCarman 

I would expect then something similar in the attribute table in Web Appbuilder: a sort of hyperlink or button that allows you to execute the Arcade script for a particular feature?

The experience that I want to provide to the end users is having all the attributes (both from parent and child) in one attribute table (attribute table of the child). This should be possible because we have a M:1 relationship between the child (incident along pipeline) and the parent (general data about the pipeline). In the pop-ups we can get this working through the Arcade script above, but it would be nice to have the same experience in the attribute table as well. 

 

Best regards

Philippe

XanderBakker
Esri Esteemed Contributor

Hi @PhilippeVDV ,

Perhaps you can get an enhanced experience using the new Arcade data expressions in Dashboard (the new one). This allows you to access any data that you have access to and transform it in a way you need. It does not apply for the map widget, but it does for most other widgets. It might be worth having a look at this capability. 

Yesterday I did a little test on some local vaccination data from Colombia and did some analysis as to when a certain phase would initiate. People have been divided into 5 groups and I wanted to know when a certain group would be able to get their vaccine. 

There are a lot of assumptions in the analysis but it does provide an indication and I am stunned by what one can do with this new capability: 

XanderBakker_0-1621603238032.png

 

0 Kudos
JenniferMcCollom1
New Contributor III

Xander,

I have heard A LOT about how these awesome arcade expressions can be used to source a widget with one-to-many data in a related (non spatial table) in the latest Dashboard, but I still have yet to see the Arcade code that makes this work. Please feel free to share how you made this happen.

0 Kudos
XanderBakker
Esri Esteemed Contributor

Hi @JenniferMcCollom1 ,

I have worked on multiple projects over the last few weeks with different use cases and all using the new Arcade data expressions and I am very excited about what it can do. If I find the time I will write something down providing the code and explanation.

PhilippeVDV
New Contributor III

Hi @XanderBakker 

 

Thanks a lot once more for your feedback!

The workaround you suggest is not an option for us unfortunately. The customer is on ArcGIS Enterprise 10.7.1. I believe the new ArcGIS Dashboard is currently only available for ArcGIS Online?

I will probably open a support ticket with Esri to discuss the [object promise] thing in Web Appbuilder. This message shouldn't be there I believe.

 

Best regards

Philippe