Select to view content in your preferred language

{relationships/0/FieldName} not working in Field Maps popup but works in the web map

906
6
09-04-2024 07:24 AM
DougBrowning
MVP Esteemed Contributor

{relationships/0/FieldName} syntax is not working in Field Maps popup but works in the web map.  This was an issue back in the old map viewer for many, many years.  I talked to @JeffShaner about it a few times but it was punted to the new map viewer.  It still seems to not work.

I am testing moving to the new map viewer for our field projects.  Currently I must use 32 Arcade expressions with FeatureSet just to look up attributes from the parent that I then use in Survey123 Launch URLs.  

DesignLat {expression/expr6}
var tbl = FeatureSetByRelationshipName($feature, "Points", ['DesignLat'], false);
return First(tbl).DesignLat

Then 
arcgis-survey123://?itemID=87ef1194dac&field:PointID={PointID}&field:DesignLat={expression/expr6}

In the popup I can add related fields using the syntax {relationships/0/FieldName} and it does work great in the browser and my URLs form properly

arcgis-survey123://?itemID=1b2594e&field:PointID={PointID}&field:CollectTurbidity={relationships/0/CollectTurbidity}

But in Field Maps it is not giving me any values for {relationships/0/CollectTurbidity} so my URL looks like  arcgis-survey123://?itemID=1b2594e&field:PointID=SomethingID&field:CollectTurbidity=  which means nothing is getting passed.

Is there some other syntax here to grab the related fields?  I am not seeing anything that says this does not work.  Is it a bug, not supported, or is there any timeline here?  It would be so nice not to have to manually add 32 Arcade expressions by hand.

thanks

6 Replies
MitchellGrafstein
Frequent Contributor

Just ballparking here... (I'm also not sure exactly what we want to end result to be?  Do we just want a URL to sling over to Survey123 that has all the fields/values you need to start with?)

Create a calculated expression, so you can use it.  It doesn't need to be applied, but that way we can use it in different places.

Perhaps, in this expression, you can first get the fields from the related table.  Grab only the fields you need by excluding the ones you do not.  In the code, I'm just getting the fields, but you could do the same and also grab the data along the way from the related FeatureSet.  From there, you can build out your URL parameters if that is what you're trying to do.  I know you're a pro, so I'm probably missing something here in the potential solution, but I figured this might be a possible way to save some typing.  Annoying that you cannot simply access the fields names from the related FeatureSet (I think), so I figured "let's go get the fields a different way", then use that to mine through the related records with our favorite fields in hand.

I've done this in pop-ups where I just loop through the fields.    Just be aware, I've seen some wonky things with FeatureSets only returning 1000 records in Field Maps where they return the full fset in the webmap viewer.  (I think I can work around that possibly, but I thought that was odd, and I think I have to tackle it a slightly different way/)

 

var rel_records = FeatureSetByRelationshipName($feature, "BK_Sites_Activities_Tbl")
var tbl_fset_schema =  First(FeatureSetById($map, "18c356a127f-layer-8"))

var fields_to_skip = ["CreationDate","Creator","EditDate","Editor","OBJECTID"]
var my_fields = []
for (var v in tbl_fset_schema) {
  if(!(Includes(fields_to_skip,v))){
  Push(my_fields,v)}
}

// get rel_records
// loop through them
// use your fields schema
// get values similar to above 

// return rel_records or format URL for related records?

return Text(my_fields)

// Tested to make sure I can return this as a calculated value or using an info element

 

This is only about 20% of the code, because it gets very specific from here, but I've created long strings of field names and values by just looping through a FeatureSet that will show up in Field Maps, so I assume you could do the same and format your URL parameters along the way.  The trick here I'm assuming is getting what field names you need from the related record schema, so you can use them in the relationship?  If not, I'm missing what we're looking for, but I hope this was somehow helpful. 

 

Mitchell Grafstein, Horticultural Inspector 1, NYS Dept. of Agriculture and Markets
0 Kudos
DougBrowning
MVP Esteemed Contributor

The Arcade I posted above is just for display as you say but that is all I need it for.  We have been using this method since before calculated expressions even existed.  But what concerns me on changing is 1.  Kicking off 32 calculated expressions could be a performance hit.  2. If anyone changes the parent layer then the children are now wrong. (that is why I dont calc much to other layers as it gets real tricky on changes).

Overall though if {relationships/0/FieldName} works in a browser then it should work in Field Maps.  The fact its been a known issue for pushing 8 years I think is kinda crazy.  Related tables really need to be better supported in general.  Its just a key database concept.

thanks

MitchellGrafstein
Frequent Contributor

I 100% agree that related records need better support.  I often find it "interesting" how many things work in one area of the Esri ecosystem and then not in others.  If everything here is working on the same web map specification, then it should seem like it should work similarly everywhere anything is based on that, but it often does not.

I had never used the effects on a layer to try and deemphasize some features over others until the other day, and it works in the Web Map Viewer, but not in Field Maps.  I have an Arcade script that returns proper numbers in the Web Map Viewer pop-ups but stops counts at 1000 records for the pop-ups in Field Maps.  (I believe in the pop-up profile, it is supposed to still return all records, but again it behaves differently.  This behavior may even only work this way online, but I have to check that.)

Hope you get the functionality that you need and that should be expected.

Mitchell Grafstein, Horticultural Inspector 1, NYS Dept. of Agriculture and Markets
DougBrowning
MVP Esteemed Contributor

Bump to @JeffShaner or maybe @ColinLawrence   if any progress on this?  Is it on the list?  I have field season builds coming up and have to make 100 arcade expressions across my projects.  This fix would eliminate all of them.

It got posted again today in the 123 board  https://community.esri.com/t5/arcgis-survey123-questions/prepopulate-field-from-related-table/m-p/15... 

Thanks

ColinLawrence
Esri Regular Contributor

Hi @DougBrowning sorry for the delay in seeing this one. I dont have the greatest answer for you but from what I have gathered it seems that Map Viewer is moving away from the /relationships/0/ syntax in favor of using arcade and for this reason runtime has decided not to address the issue you are pointing out with pulling in the relationship field values. By using arcade to generate these URLs you are already using the recommended practice. 

Regards,
Colin
DougBrowning
MVP Esteemed Contributor

That is a bummer it would be way less work and it is already working great in the map viewer - it is only Field Maps where it does not work.  We seem to keep losing more and more functionality over time honestly.  Esp the new JS 4.0 tools.

thanks

0 Kudos