Select to view content in your preferred language

Related Table info not showing in field maps pop up.

1569
4
11-30-2021 11:04 AM
JaredJones
Emerging Contributor

I setup arcade expressions on a hosted feature layers pop up window to show data from a related table in it. While in Map Viewer Classic the data show ups fine. When I open collector or field maps the data is then missing. There is a 1:M relationship between the Hosted Feature Layer and the related table. 

One of my sets of code is 

var relatedrecords = OrderBy(FeatureSetByRelationshipName($feature,"WDM_DigitalEnt.DBO.issues_struct"), "IssueDate DES");
var cnt = Count(relatedrecords);
var relatedinfo = "";
if (cnt > 0) { var info = First(relatedrecords);
relatedinfo = Text(ToLocal(info.IssueDate), "MM/DD/Y");
}
return relatedinfo;

0 Kudos
4 Replies
ABishop
MVP Regular Contributor

Hello Jared,

Maybe check the permissions on the table?  

Amanda Bishop, GISP
0 Kudos
DougBrowning
MVP Esteemed Contributor

I am pretty sure Feature set is Field Maps and up only (not collector) since I was waiting on it.  Also note the related table needs to be in the map and in the downloaded area.

I have had better luck using the name of the layer from the map.

Note replace * with the field name you want and it will be faster.  The false part is no geo so also faster.  

var sql = "PointID = '" + $feature.PointID + "'";
var tbl = Filter(FeatureSetByName($map,"Points", ['*'], false), sql);
return First(tbl).DesignLong

Hope that helps

0 Kudos
JaredJones
Emerging Contributor

Doug,

All layers and tables are within the map. You mentioned downloaded area but I am not using offline maps for this. I am an arcade novice and my previous code was created with help from other threads on this site. I tried swapping out my code for yours and replacing the * with the field in the related table I need to pull data from and it gave me the error "Execution Error:Field not Found : PointID".

 

Update: Here is what I just tried using for code based off your earlier reply Doug. 

var sql = "PointID = '" + $feature.IssueDate + "'";
var tbl = Filter(FeatureSetByName($map,"Dashboard_Inspection - IssuesStructures",['IssueDate'], false, sql);
return First(tbl).DesignLong

I got a different error this time and it says " Parse Error:Line 2: Unexpected token ; "

0 Kudos
DougBrowning
MVP Esteemed Contributor

You need to change the query to the field you want.  What is your PrimaryKey?  I am sure IssueDate is not it.

var sql = "YourKeyHere = '" + $feature.YourKeyHere + "'";

You are just building a query string to grab the right record in the related table.

and of course need to update this part 

return First(tbl).FieldYouWantHere

0 Kudos