Select to view content in your preferred language

ArcGIS Pro popup element not sticking

242
3
07-03-2024 10:42 PM
Sian_Doherty_GHD
New Contributor II

I have configured popups in ArcGIS Pro but they sometimes don't stick.
There are multiple layers where this is a problem and for the most part the majority of the fields are the same with some additions depending on the asset type. 
The gist of my popup element is 

 

 

var popupContent = "<table style='border-collapse: collapse;'>"; // Initialize popup content as an HTML table
var fields = []; // Array to hold the fields and their values
var cellPadding = "8px"; // Adjust padding as needed
// Access feature attributes and push them into the fields array
Push(fields, { name: "Facility ID", value: $feature.facility_ID });
Push(fields, { name: "Name", value: $feature.name });
Push(fields, { name: "Description", value: $feature.description });
Push(fields, { name: "Asset Status", value: DomainName($feature,"asset_status") });
Push(fields, { name: "Beam Type", value: DomainName($feature,"type") });
Push(fields, { name: "Beam Position", value: DomainName($feature,"position") });
Push(fields, { name: "Material", value: DomainName($feature,"material") });
Push(fields, { name: "Install Date", value: Text($feature.install_date,"dddd DD MMMM Y") });
Push(fields, { name: "Length", value: Round($feature.length,2) + " "+ DomainName($feature,"distance_UOM")});
Push(fields, { name: "Width", value: Round($feature.width,2) + " "+ DomainName($feature,"distance_UOM")});
Push(fields, { name: "Maintained By", value: DomainName($feature,"maintained_by") });
Push(fields, { name: "Owner", value: DomainName($feature,"ownership") });
Push(fields, { name: "Condition Assessment Rating", value: DomainName($feature,"ca_rating") });
Push(fields, { name: "Condition Assessment Date", value: Text($feature.ca_date,"dddd DD MMMM Y") }); // Include formatted CA date directly
Push(fields, { name: "Condition Assessment Comments", value: $feature.ca_comments });
Push(fields, { name: "Collection Method", value: $feature.collection_method });
Push(fields, { name: "Source", value: $feature.source });
Push(fields, { name: "Source Date", value: Text($feature.source_date,"dddd DD MMMM Y") });
Push(fields, { name: "Berth", value: $feature.berth});
Push(fields, { name: "Precinct", value: $feature.wharf});
Push(fields, { name: "Port", value: DomainName($feature,"terminal")});
Push(fields, { name: "Comments", value: $feature.comments});

// Count the number of non-empty fields
var validFieldCount = 0;
for (var i = 0; i < Count(fields); i++) {
    var field = fields[i];
    if (field.value != null && field.value != "" && field.value != 0 && field.value != 0 + " ") {
        validFieldCount++;
    }
}
// Add fields to popup content
for (var i = 0; i < Count(fields); i++) {
    var field = fields[i];
    if (field.value != null && field.value != "" && field.value != 0 && field.value != 0 + " ") {
        popupContent += "<tr style='background-color:" +  "'><td style='padding:" + cellPadding + "'><b>" + field.name + ":</b></td><td style='padding:" + cellPadding + "; '>" + field.value + "</td></tr>";
    }
}
popupContent += "</table>"; // Close the HTML table tag
// Return statement adjusted for popupElement
return {
    type: "text",
    text: popupContent
};

 

Sometimes it reverts to 

 

 

var popupContent = " " + field.name + ": " + field.value + " "; // Close the HTML table tag // Return statement adjusted for popupElement return { type: "text", text: popupContent };

 

 

Other times it can revert to 

 

 

return {
type: "text",
text: popupContent
};

 

which is the default arcade element text option when clicking on the 'Arcade' button in the configure popups dialog box in ArcGIS Pro. 

I cannot for the life of me figure out what is going on. i have checked the field types and names and it will preview OK, but it just doesn't stick. Can anyone help or should i escalate to tech support?

The reason i'm specific with my listing of fields is because i have another question pending about the fields being returned in alphabetical order when i use the following as my popup:

 

 

var popupContent = "<table style='border-collapse: collapse;'>";
var cellPadding = "8px"; // Adjust padding as needed

// Field map to hold the field names and their corresponding values
var fieldMap = {
    "Facility ID": $feature.facility_ID,
    "Name": $feature.name,
    "Description": $feature.description,
    "Wharf": $feature.wharf,
    "Berth": $feature.berth,
    "Condition Assessment Rating": $feature.ca_rating,
    "Condition Assessment Date": Text($feature.ca_date, "dddd DD MMMM Y"),
    "Condition Assessment Comments": $feature.ca_comments,
    "Collection Method": $feature.collection_method,
    "Source": $feature.source,
    "Source Date": Text($feature.source_date, "dddd DD MMMM Y")
};

// Add fields to popup content
var i = 0;
for (var fieldName in fieldMap) {
    var fieldValue = fieldMap[fieldName];
    if (fieldValue != null && fieldValue != "") {
        var rowColor;
        if (i % 2 == 0) {
            rowColor = "#FBFBFB";
        } else {
            rowColor = "#EDEDED";
        }
        popupContent += "<tr style='background-color:" + rowColor + "'><td style='padding:" + cellPadding + "'><b>" + fieldName + ":</b></td><td style='padding:" + cellPadding + "'>" + fieldValue + "</td></tr>";
        i++;
    }
}

popupContent += "</table>";

// Return statement adjusted for popupElement
return { 
type: "text", 
text: popupContent 
};

 

Warm regards,

 

Sian Doherty

Spatial Analyst (GHD Digital)

 

0 Kudos
3 Replies
palatisa1
New Contributor

Do this and force I think the cache running to stop. You can usually salvage it this route. Project recovery is also mostly good if it crashes. I tend to pause the map OP if I know I’m gonna add a lot of data.

0 Kudos
palatisa1
New Contributor

@palatisa1 wrote:

Do this and force I think the cache running to stop. You can usually salvage it this route. Project recovery is also mostly good if it crashes. I tend to pause the map OP if I know I’m gonna add a lot of data https://9apps.ooo/ .


I got this,..

0 Kudos
Sian_Doherty_GHD
New Contributor II

Thanks @palatisa1 

Unfortunately project recovery will do nothing as even if I save the project after previewing the successful pop-up, it just doesn't stick. Cache is set to clear upon exit. I've just got snippets saved as .js files and I usually just copy and paste it back prior to publishing. However, sometimes that works and sometimes it doesn't, so i'm looking for a permanent solution. 

0 Kudos