Select to view content in your preferred language

Returning a field from a stand-alone table to a feature service popup using Arcade

267
10
09-09-2024 08:25 AM
DaveK
by
Frequent Contributor

Hello! 

I have a stand-alone table in ArcGIS Online that I would like to link to a feature service. The table and feature service are not related but both contain a common field. Is it possible to use Arcade to pull back records from the table into the feature service popup where the records match? Any help is appreciated. 

Thanks. 

0 Kudos
10 Replies
KenBuja
MVP Esteemed Contributor

Yes, you can do this by using the Filter function. This code returne all the records in the table that have same attribute in the common field

var asset = $feature.theCommonField;
var fs = FeatureSetByPortalItem(
  Portal('yourPortal'),
  'itemId',
  0,
  ['*'],
  false
);
var related = Filter(fs, "theCommonField = @asset");

 

0 Kudos
DaveK
by
Frequent Contributor

Hey @KenBuja, Thanks for this! Can you expand on it a bit and assist in setting my expression up? I'm assuming I'm inputting something wrong or missing something as I'm getting an error. Here's my setup below. The ID within the portal is the ID for the stand-alone table.

 

var asset = $feature.PWID;
var fs = FeatureSetByPortalItem(
  Portal('https://njdep.maps.arcgis.com/'),
  'e6854954c9a744e09a0cfbe777d20492',
  0,
  ['*'],
  false
);
var related = Filter(fs, "PWID = @asset");

 

 

0 Kudos
KenBuja
MVP Esteemed Contributor

What is the error that you're getting? Also, have you checked whether the layerId is correct?

0 Kudos
DaveK
by
Frequent Contributor

The ID is correct. The error I get is "Test execution error: Unknown Error. Verify test data."

0 Kudos
KenBuja
MVP Esteemed Contributor

If you put in "return fs" between line 8 and 9 and hit the Run button in the upper left corner, do you get back a valid dataset?

0 Kudos
DaveK
by
Frequent Contributor

I get the same error. 

0 Kudos
KenBuja
MVP Esteemed Contributor

Either the itemId ('e6854954c9a744e09a0cfbe777d20492') or the layerId (0) is incorrect.

0 Kudos
DaveK
by
Frequent Contributor

Ah, it looks like it was the layerID(0). I changed it to 1 and now it works but I dont seem to get any results in the popup. I added "return related" and see results in the expression box but again nothing in the popup. 

0 Kudos
KenBuja
MVP Esteemed Contributor

If you know there should be related records, the next step would be to make sure the field name is correct in the Filter statement

0 Kudos