Select to view content in your preferred language

Obtaining Record Attributes from a Hosted Table to Display in Feature Layer Pop-up with Arcade Expression

1202
4
04-01-2023 12:42 AM
Labels (3)
HebahFarrag
New Contributor

I'm having trouble figuring out how to retrieve a field from a standalone hosted table and show it in the pop-up of a hosted feature layer. Can anyone assist?

Data Item Overview:
exemplar_list_testing (hosted feature layer)

exemplar_list_testing.png

 

 

exemplar_publication_testing (hosted table)

exemplar_publication_testing.png

 

I aim to display the 'paragraph_description' field in the feature layer pop-up from the hosted table.

Current Arcade Expression:

 

var ExemplarListID = $feature.UniqueID;
var ExemplarPublicationGID = "ExemplarListID = @ExemplarListID";

var ExemplarPublications = FeatureSetByName($map, "exemplar_publication_testing");
var RelatedData = Filter(ExemplarPublications, ExemplarPublicationGID);

var popupstring = "";
for (var ExemplarPublication in RelatedData){
    
    popupstring += "Paragraph Description:  " + ExemplarPublication.Paragraph_Description + TextFormatting.NewLine;
    
}
popupstring += TextFormatting.NewLine;

return popupstring;

 

 

 

 

Tags (3)
0 Kudos
4 Replies
ChristopherCounsell
MVP Regular Contributor

There is an issue with the expression in the second line:

var ExemplarPublicationGID = "ExemplarListID = @ExemplarListID";


This line is setting the variable ExemplarPublicationGID to a string, which contains the literal text "ExemplarListID = @ExemplarListID". This is not a valid Arcade expression and will not evaluate correctly.

Instead, the expression should reference the variable ExemplarListID directly, like this:

var ExemplarPublicationGID = "ExemplarListID = '" + ExemplarListID + "'";

This sets ExemplarPublicationGID to a string that contains the value of ExemplarListID, enclosed in single quotes. This will allow the expression to be used as a filter in the Filter function.

0 Kudos
KenBuja
MVP Esteemed Contributor

You can use variable substitution (see the Filter help) like that, shown here:

arcade.png

0 Kudos
KenBuja
MVP Esteemed Contributor

There is no ExemplarListID field in the exemplar_publication_testing table. Your sql expression should be

var ExemplarPublicationGID = "UniqueID = @ExemplarListID";
0 Kudos
ChristopherCounsell
MVP Regular Contributor

var ExemplarPublicationGID = "UniqueID= '" + ExemplarListID + "'";

0 Kudos