Well, that's encouraging. The thing is, I can't seem to access globals like $map from any of the layers (see screenshot).
I can't share the map service or the portal map as both are internal to my org. But basically everything is coming from an enterprise gdb. The service has a dozen or more feature layers but for this example, I'll just name one or two. I'm trying to accomplish the same thing for each feature layer: build a pop-up that includes some data from fields from a related table. There's relationship classes built between each of them and the related table (I'll call it "Link Table" here). Feature layers and related table share a common field "BLDG_ID".
Let's say, click on a point from "Building Points" layer, and it'll show data from fields in Link Table such as "Field1_ID", "Field2_ID". Relating from the layer to the link table should generally return only one result.
I've a web map in portal that pulls all layers from the map service. I'll be generic and give an idea of how the service is structured:
Map Service:
https ://mymapservices.com/arcgis/rest/services/BldgData/MapServer
Map Name: Building Data
Layers:
- Building Point (0)
- Building Poly (1)
Tables:
-----
Layer: Building Point (ID: 0)
Name: Building Point
Fields:
- OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
- RESNAME ( type: esriFieldTypeString , alias: Resource Name , length: 250 )
- BLDG_ID ( type: esriFieldTypeString , alias: BLDG_ID , length: 5 )
Relationships:
- MyBldgDB.DBO.Link_Table (0) -- Related To: LINK TABLE (20)
------
Layer: LINK TABLE (ID: 20)
Name: LINK TABLE
- OBJECTID ( type: esriFieldTypeOID , alias: OBJECTID )
- BLDG_ID ( type: esriFieldTypeString , alias: BLDG_ID , length: 5 )
- FIELD1_ID ( type: esriFieldTypeString , alias: FIELD1_ID , length: 5 )
- FIELD2_ID ( type: esriFieldTypeString , alias: FIELD2_ID , length: 5 )
Relationships:
- MyBldgDB.DBO.BLDG_PT (0) -- Related To: Building Point (0)
- MyBldgDB.DBO.BLDG_PY_ (1) -- Related To: Building Poly (1)
----
Portal web map has all layers pulled from this service under BldgData in ToC.
Not sure if this is helpful so I can try to simplify if need be.