Select to view content in your preferred language

Updating pop ups with new survey123 data from another layer, displaying multiple layer's data in one popup, autoselecting the most recent entry

158
2
2 weeks ago
KateSweet
New Contributor

Hi there,

I apologize I'm fairly new to using ESRI products.

I'm trying to make a field map where I have several points where field teams regularly visit to collect data. I am planning to use field maps with these point locations that then pop up to be able to collect Survey123 data at these points using two surveys.

One survey is called monitoring about what's happening at each of the points (what wildlife are present). The other survey called status is regarding physical characteristics of the points. I want to be able to change the displayed data in the pop up about the point to be based on the newest entry from the survey for status. For example, the layer might originally say no, a maintenance visit has not been completed. When someone submits a survey123  status form this year and says yes I've visited, I want to change the answer to yes. How do I replace the old information in the popup window with the new information?

I also wonder if its possible to have a popup that has multiple links to the tables for the two surveys (so a link to each survey and a link to view each survey's table for that particular point, such that if you were at point F1 you could click on the tables with in F1's popup easily to view the history for that  location). This would meaning calling on multiple layers in the same pop-up. Is that possible?

Is it also possible to add more information to the layer such that the most recent entry from either survey for each point is displayed on the point's pop-up? So this would be somehow selecting the most recent entry from each survey and having it be on a pop up, in addition to the original fixed information about the location. Is there a way to use code to select the most recent entry by a unique ID from a particular column?

Thanks so much for reading and for your help,

Kate 

0 Kudos
2 Replies
LindsayRaabe_FPCWA
MVP Regular Contributor

Fair bit on the go there and not sure I got my head around exactly what you're looking for. Have a read of the below posts where I asked questions similar to yours whilst learning early on.  It definitely is possible to look up feature attributes from other layers. You can do this using normal lookups, (e.g. by a linking value) or by searching within a distance (buffer) and getting intersecting features. 

Solved: Can I populate a popup with data from a different ... - Esri Community

Help writing Arcade to get distinct values from intersection in Field Maps

Also, if you're wanting to update a feature in Field Maps after completing a Survey in S123, then callbacks may be what you're looking for (though depends on how you're launching your survey):

Solved: Help with Survey123 link from Field Maps with call... - Esri Community

Below is an example popup in one of my maps that when clicking on an Local Government boundary searches (intersects) with a Plantation layer and returns values and statistics. 

LindsayRaabe_FPCWA_0-1736226717330.png

This is what you see in the popup designer:

LindsayRaabe_FPCWA_1-1736226790795.png

and a sample of the arcade coding used in the Plantation species summary:

//Requires that the FPC Plantations layer is also present in the map or lookups won't work

// Return LGA name and format nicely
var LGAname = proper(Split($feature.name, ", ")[1] + " " + Split($feature.name, ",")[0])

// Access the Plantations feature set, limiting to required fields only 
var PlantationsFS = FeatureSetByName($map, "FPC Plantations",['Plantation', 'Map_Symbol', 'AreaHa'], False)
var SoftwoodFS = Filter(PlantationsFS, "Map_Symbol = 'Softwood'")
var HardwoodFS = Filter(PlantationsFS, "Map_Symbol = 'Hardwood'")
var SandalwoodFS = Filter(PlantationsFS, "Map_Symbol = 'Sandalwood'")
var OtherFS = Filter(PlantationsFS, "Map_Symbol = 'Other Species'")
var FallowFS = Filter(PlantationsFS, "Map_Symbol = 'Fallow'")

// Intersect the Plantations with selected LGA feature
var Ptns_fs = Intersects(PlantationsFS, $feature)
var Softwood_fs = Intersects(SoftwoodFS, $feature)
var Hardwood_fs = Intersects(HardwoodFS, $feature)
var Sandalwood_fs = Intersects(SandalwoodFS, $feature)
var Other_fs = Intersects(OtherFS, $feature)
var Fallow_fs = Intersects(FallowFS, $feature)

// Count the Plantations
var PlantationsCount = Count(Distinct(Ptns_fs, "Plantation"))     //returned in popup
var SoftwoodCount = Count(Distinct(Softwood_fs, "Plantation"))     //used in calulating areas only
var HardwoodCount = Count(Distinct(Hardwood_fs, "Plantation"))     //used in calulating areas only
var SandalwoodCount = Count(Distinct(Sandalwood_fs, "Plantation"))     //used in calulating areas only
var OtherCount = Count(Distinct(Other_fs, "Plantation"))     //used in calulating areas only
var FallowCount = Count(Distinct(Fallow_fs, "Plantation"))     //used in calulating areas only

//Calculate Total Area total (the values below are overwritten by the if statement)
var PlantationsArea = 0
var PlantationsResult = ""
// check to see if there are Softwood Plantations in the LGA
if (PlantationsCount > 1) {
    // calculate the sum of AreaHa
    PlantationsArea = Sum(Ptns_fs , "AreaHa");
    PlantationsResult = Round(PlantationsArea,0) + " Ha across " + PlantationsCount + " plantations";
} else {
    if (PlantationsCount == 1) {
        // calculate the sum of AreaHa
        PlantationsArea = Sum(Ptns_fs , "AreaHa");
        PlantationsResult = Round(PlantationsArea,0) + " Ha in " + PlantationsCount + " plantation";
    } else {
    PlantationsResult = "No plantations in " + LGAname;
    }
}

//Calculate Softwood Area total (the values below are overwritten by the if statement)
var SoftwoodArea = 0
var SoftwoodResult = ""
// check to see if there are Softwood Plantations in the LGA
if (SoftwoodCount > 1) {
    // calculate the sum of AreaHa
    SoftwoodArea = Sum(Softwood_fs , "AreaHa");
    SoftwoodResult = Round(SoftwoodArea,0) + " Ha across " + SoftwoodCount + " plantations";
} else {
    if (SoftwoodCount == 1) {
        // calculate the sum of AreaHa
        SoftwoodArea = Sum(Softwood_fs , "AreaHa");
        SoftwoodResult = Round(SoftwoodArea,0) + " Ha in " + SoftwoodCount + " plantation";
    } else {
    SoftwoodResult = "No softwood";
    }
}

//Calculate Hardwood Area total (the values below are overwritten by the if statement)
var HardwoodArea = 0
var HardwoodResult = ""
// check to see if there are Hardwood Plantations in the LGA
if (HardwoodCount > 1) {
    // calculate the sum of AreaHa
    HardwoodArea = Sum(Hardwood_fs , "AreaHa");
    HardwoodResult = Round(HardwoodArea,0) + " Ha across " + HardwoodCount + " plantations";
} else {
    if (HardwoodCount == 1) {
        // calculate the sum of AreaHa
        HardwoodArea = Sum(Hardwood_fs , "AreaHa");
        HardwoodResult = Round(HardwoodArea,0) + " Ha in " + HardwoodCount + " plantation";
    } else {
    HardwoodResult = "No hardwood";
    }
}
//Calculate Sandalwood Area total (the values below are overwritten by the if statement)
var SandalwoodArea = 0
var SandalwoodResult = ""
// check to see if there are Sandalwood Plantations in the LGA
if (SandalwoodCount > 1) {
    // calculate the sum of AreaHa
    SandalwoodArea = Sum(Sandalwood_fs , "AreaHa");
    SandalwoodResult = Round(SandalwoodArea,0) + " Ha across " + SandalwoodCount + " plantations";
} else {
    if (SandalwoodCount == 1) {
        // calculate the sum of AreaHa
        SandalwoodArea = Sum(Sandalwood_fs , "AreaHa");
        SandalwoodResult = Round(SandalwoodArea,0) + " Ha in " + SandalwoodCount + " plantation";
    } else {
    SandalwoodResult = "No sandalwood";
    }
}

//Calculate Other Species Area total (the values below are overwritten by the if statement)
var OtherArea = 0
var OtherResult = ""
// check to see if there are Other Species Plantations in the LGA
if (OtherCount > 1) {
    // calculate the sum of AreaHa
    OtherArea = Sum(Other_fs , "AreaHa");
    OtherResult = Round(OtherArea,0) + " Ha across " + OtherCount + " plantations";
} else {
    if (OtherCount == 1) {
        // calculate the sum of AreaHa
        OtherArea = Sum(Other_fs , "AreaHa");
        OtherResult = Round(OtherArea,0) + " Ha in " + OtherCount + " plantation";
    } else {
    OtherResult = "No other species";
    }
}

//Calculate Fallow Area total (the values below are overwritten by the if statement)
var FallowArea = 0
var FallowResult = ""
// check to see if there are Fallow areas in the LGA
if (FallowCount > 1) {
    // calculate the sum of AreaHa
    FallowArea = Sum(Fallow_fs , "AreaHa");
    FallowResult = Round(FallowArea,0) + " Ha across " + FallowCount + " plantations";
} else {
    if (FallowCount == 1) {
        // calculate the sum of AreaHa
        FallowArea = Sum(Fallow_fs , "AreaHa");
        FallowResult = Round(FallowArea,0) + " Ha in " + FallowCount + " plantation";
    } else {
    FallowResult = "No fallow areas";
    }
}


// Output dictionary as fields to display in the pop-up

return {
    type: 'fields',
    title: 'Plantation Summary (by species)',
    //description : "",
    fieldInfos:  [{
          fieldName: " "  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "All Species"  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "Softwood"  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "Hardwood"  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "Sandalwood"  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "Other Species"  // fieldName should match the key in the attributes dictionary
        },
        {
          fieldName: "Fallow"  // fieldName should match the key in the attributes dictionary
        }],
    attributes : {"All Species" : PlantationsResult, "Softwood" : SoftwoodResult, "Hardwood" : HardwoodResult, "Sandalwood" : SandalwoodResult, "Other Species" : OtherResult, "Fallow" : FallowResult}  // replace this dictionary with your own key-value pairs
}

  

Lindsay Raabe
GIS Officer
Forest Products Commission WA
AndreasHall
Esri Contributor

Hi, I would recommend you to look up this video series: Inspection Workflows Part 1: Building & Publishing Related Tables. To me it sounds like you could find some useful tips there. 

Also take a look at Use related data in pop-ups—ArcGIS Pro | Documentation and Pulling Related Records with Arcade.