Hello,
I have an Arcade expression that has worked perfectly in other applications but is returning some odd results after I repurposed it in another map. Here's the expression:
var parcelPID = $feature.PID;
var relatedForms = FeatureSetByName($map, "UBTEST - Epgdb.engineering.UB test2")
var filterStatement = "g2_UB_PID = @parcelPID"
var ubRecords = Filter(relatedForms, filterStatement)
var ubRecordsSorted = OrderBy(ubRecords, 'RowNumber DESC')
var popupString = ''
for (var f in ubRecordsSorted){
popupString +=
`${f.Rownumber}<br>
<b>AccountNum: </b>${f.g2_AccountNumber}<br>
<b>PID: </b>${f.g2_UB_PID}<br>
<b>Meter #: </b>${f.g5_MeterNumber}<br>
<b>Meter Type: </b>${f.m3_MeterType}<br>
<b>Install Date: </b>${f.g5_DateInstalled}<br>
<b>Serial: </b>${f.m3_SerialNumber}<br>
<br>
`
}
return {
type : 'text',
text : popupString
}
What it should do is search the table UB_Test_2 for all the rows that have the same g2_UB_PID and return meter information. Here's an example of the test 2 table. The identified parcel is the parent feature, and the two records shown in the table both have the same PID:
However, running the expression above, only one of those two records is returned, and it is retuned twice:
This persists across all features, where the number of possible related records is returned, but only information from one of the records populates all the returns. As I mentioned, essentially this same expression (different datasets and just different fields used in the filter and return, with the same expression structure) works just fine.
The next step it to to see what the ubRecordsSorted FS contains. Put in a return statment on line 11 and see if you're getting the same records multiple times.
Confirmed, multiple duplicate records.
My guess it has something to do with the way the data is constructed. The UB table is a SQL view matching up two other tables, but if that were the case, it seems weird that I should be able to open the table and see different records