I have a polygon layer where one polygon matches multiple records in a table. I use JoinDataSource() to join these two items so I can set the definition expression of the polygon layer based on a field in the table. When I go to set the popup content for this polygon feature I need to query the records in the table that are related with the polygon layer. To use a relationship query, you need the objectId of the polygon, but I can't get that using feature.attributes.fieldName because the field name itself has a bunch of periods in it due to the database and tables names being prefixed on it. Using something like this won't work because javascript misinterprets the periods:
feature<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN>HabitatManagement<SPAN class="punctuation token">.</SPAN>DBO<SPAN class="punctuation token">.</SPAN>MgmtTracts<SPAN class="punctuation token">.</SPAN>OBJECTID<SPAN class="line-numbers-rows"><SPAN></SPAN></SPAN>
How do I get around this?
Here is the relationship query code:
<SPAN class="keyword token">function</SPAN> <SPAN class="token function">mgmtPopupContent</SPAN><SPAN class="punctuation token">(</SPAN>feature<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="keyword token">var</SPAN> OID <SPAN class="operator token">=</SPAN> feature<SPAN class="punctuation token">.</SPAN>attributes<SPAN class="punctuation token">.</SPAN>HabitatManagement<SPAN class="punctuation token">.</SPAN>DBO<SPAN class="punctuation token">.</SPAN>MgmtTracts<SPAN class="punctuation token">.</SPAN>OBJECTID<SPAN class="punctuation token">;</SPAN>
<SPAN class="keyword token">var</SPAN> relatedQuery <SPAN class="operator token">=</SPAN> <SPAN class="keyword token">new</SPAN> <SPAN class="token class-name">RelationshipQuery</SPAN><SPAN class="punctuation token">(</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">;</SPAN>
relatedQuery<SPAN class="punctuation token">.</SPAN>outFields <SPAN class="operator token">=</SPAN> <SPAN class="punctuation token">[</SPAN><SPAN class="string token">"*"</SPAN><SPAN class="punctuation token">]</SPAN><SPAN class="punctuation token">;</SPAN>
relatedQuery<SPAN class="punctuation token">.</SPAN>relationshipId <SPAN class="operator token">=</SPAN> <SPAN class="number token">0</SPAN><SPAN class="punctuation token">;</SPAN>
relatedQuery<SPAN class="punctuation token">.</SPAN>objectIds <SPAN class="operator token">=</SPAN> OID<SPAN class="punctuation token">;</SPAN>
hbMgmtTractFL<SPAN class="punctuation token">.</SPAN><SPAN class="token function">queryRelatedFeatures</SPAN><SPAN class="punctuation token">(</SPAN>relatedQuery<SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">function</SPAN><SPAN class="punctuation token">(</SPAN>relatedRecords<SPAN class="punctuation token">)</SPAN> <SPAN class="punctuation token">{</SPAN>
<SPAN class="comment token">//set popup content</SPAN>
<SPAN class="punctuation token">}</SPAN>
<SPAN class="punctuation token">}</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>