Custom pop-up attributes loading incorrectly in mobile app

10-25-2021 04:36 AM
New Contributor

Hello, I've been trying to develop some custom attributes that display results from related data tables within the pop-up. I have encountered a problem where the pop-up is displaying a different (often incorrect) result each time it's loaded, when the web map viewer is showing the correct result each time.

I have a layer of point features (Trees) that have related data tables (Tree Inspections), which are used to record the condition of the tree, when it was watered, when it was mulched, etc.

I am using variations on the following code to load records from the related data tables:



var inspections = FeatureSetByRelationshipName($feature,"Tree Inspections", ['createddate','atrisk'], false)

// Filter records
var filterStatement = 'atrisk IS NOT NULL'
var filteredData = Filter(inspections, filterStatement)

// Select most recent record
var lastRecord = Top( OrderBy(filteredData, 'createddate DESC'), 1)

// Build the pop-up string by iterating through all related features
var popupString = ''
for (var f in lastRecord){
        popupString += DefaultValue(f.atrisk, "nodata") + " (" +
        Text(f.createddate, 'DD MM YY') + ")"

DefaultValue(popupString, 'Not at risk')



The above code should load the most recent record for whether the tree is 'at risk', and similar code operates for 'last recorded condition', 'last watered' and 'last mulched'.

The correct results are displayed in the pop-up on the web map viewer:


However, when loaded in the Field Maps Mobile App (android most recent version), the results constantly change, even though the underlying data remains the same:







I think it's something to do with how the related dataset is being loaded - perhaps the loading is not completed before the pop-up and results are shown, so the sorting and picking functions in the code are running on an incomplete dataset.

I would greatly appreciate any help in getting to the bottom of this issue.





0 Kudos
1 Reply
Occasional Contributor III

I'm doing the same, tree inspections.  I didn't encounter your issue (yet) but I'm still in the early stages of development. Did you have any progress on this?

0 Kudos