|
POST
|
@MariusVerdes It looks like if you type the .xlsx extension at the end of the file name in the GP tool you can get the xlsx file format. The output folder shows that it supports XLS or XLSX
... View more
08-20-2024
08:46 AM
|
6
|
0
|
2632
|
|
POST
|
@TonyAlmeida @HaydenWelch , apologies for the delayed response, I was not getting notifications on this post for some reason. It turned out the issue was that the Vector Tile Package could not overwrite the older file with the same name if it was in the same folder. I created a support ticket with Esri, and we discovered that if I moved the original VTPK to a folder, and then had the script import the newer VTPK with the same file name to the parent folder, it did not cause the issue.
... View more
08-16-2024
01:12 PM
|
0
|
0
|
1020
|
|
POST
|
I am trying to batch-update multiple layers to all have the same Arcade content applied. I have found documentation on using a combination of Attribute Expressions / Text elements, but for the particular Arcade I am using, it only functions correctly if Arcade content is applied. I have looked through the developer documentation and it does not appear to call out Arcade as a popupElement supported function. Here is my current code, but ultimately I would like to remove the Attribute Expression and Text element and use Arcade as this works for hyperlinking out to URLs. from arcgis.gis import GIS
from arcgis.mapping import WebMap
# Step 1: Connect to the Portal
gis = GIS("https://portal.website.com/portal/", "username", "password")
# Step 2: Access the Web Map
webmap_item = gis.content.get("itemid")
webmap = WebMap(webmap_item)
# Function to clean popupInfo, remove attribute expressions, text boxes, and fields list
def clean_popup(layer):
# Update the layer title to remove ":" and references to "fields"
if "title" in layer:
original_title = layer["title"]
new_title = original_title.replace(':', '').replace('fields', '', 1).strip()
layer["title"] = new_title
if original_title != new_title:
print(f"Updated layer title from '{original_title}' to '{new_title}'")
# Clean the popupInfo to remove attribute expressions, fields list, and text boxes
if "popupInfo" in layer:
popup_info = layer["popupInfo"]
# Clear popupElements to remove Fields list, text elements, and any other custom elements
popup_info["popupElements"] = []
# Remove fieldInfos and attribute expressions (expressionInfos) completely
popup_info.pop("fieldInfos", None)
popup_info.pop("expressionInfos", None) # Removes any existing attribute expressions
# Remove other potential field-related properties
field_related_keys = ['displayField', 'description', 'showAttachments', 'mediaInfos']
for key in field_related_keys:
popup_info.pop(key, None)
print(f"Cleaned popupInfo for layer: {layer.get('title', 'Unnamed Layer')}")
# Function to add an Arcade attribute expression and reference it in a text element
def add_arcade_expression_as_text(layer):
if "popupInfo" in layer:
popup_info = layer["popupInfo"]
# Define the Arcade attribute expression
arcade_expression = {
"name": "customContent",
"title": "Custom Content",
"expression": """
var fieldsToExclude = ["OBJECTID", "OBJECTID_1", "SHAPE", "LAYERNAME", "GLOBALID", "SHAPE.STAREA()", "SHAPE.STLENGTH()", "CREATED_USER", "CREATED_DATE", "LAST_EDITED_USER", "LAST_EDITED_DATE", "LASTMODBY", "LASTMODDATE", "LASTSYNDATE"];
var content = "";
var seenUrls = {};
function formatURL(label, value) {
return label + ": <a target='_blank' href='" + value + "'>Click here for more info.</a>";
}
Expects($feature, "*");
var schemaDict = Schema($feature);
var fieldsArray = schemaDict["fields"];
function getFieldAlias(fieldName) {
for (var j = 0; j < Count(fieldsArray); j++) {
var fieldDict = fieldsArray[j];
if (fieldDict['name'] == fieldName) {
return fieldDict['alias'];
}
}
return fieldName;
}
function formatDate(dateValue) {
var date = Date(dateValue);
return Text(date, "MM/DD/YYYY");
}
function getDomainDescription(fieldDict, value) {
if (HasKey(fieldDict, "domain")) {
var domain = fieldDict["domain"];
if (domain != null && HasKey(domain, "codedValues")) {
for (var k = 0; k < Count(domain["codedValues"]); k++) {
var codedValue = domain["codedValues"][k];
if (codedValue["code"] == value) {
return codedValue["name"];
}
}
}
}
return value;
}
for (var i = 0; i < Count(fieldsArray); i++) {
var fieldDict = fieldsArray[i];
var fieldName = fieldDict["name"];
var alias = fieldDict["alias"];
var value = $feature[fieldName];
if (IndexOf(fieldsToExclude, Upper(fieldName)) == -1 && !IsEmpty(value) && Upper(Text(value)) != "NULL") {
if (Upper(Left(Text(value), 7)) == "HTTP://" || Upper(Left(Text(value), 8)) == "HTTPS://") {
if (!HasKey(seenUrls, value)) {
content += formatURL(alias, value) + "\\n";
seenUrls[value] = true;
}
} else if (fieldDict.type == "esriFieldTypeDate") {
content += alias + ": " + formatDate(value) + "\\n";
} else if (HasKey(fieldDict, "domain") && fieldDict["domain"] != null) {
var domainDescription = getDomainDescription(fieldDict, value);
content += alias + ": " + Text(domainDescription) + "\\n";
} else {
content += alias + ": " + Text(value) + "\\n";
}
}
}
return content;
"""
}
# Add the Arcade expression to the expressionInfos
if "expressionInfos" not in popup_info:
popup_info["expressionInfos"] = []
popup_info["expressionInfos"].append(arcade_expression)
# Reference the Arcade expression in a text element
text_element = {
"type": "text",
"text": "{expression/customContent}"
}
# Add the text element to the popupElements
popup_info["popupElements"].append(text_element)
print(f"Added Arcade expression as a text element to layer: {layer.get('title', 'Unnamed Layer')}")
# Recursive function to process all layers, including nested layers
def process_layers(layers):
for layer in layers:
clean_popup(layer)
add_arcade_expression_as_text(layer)
# Process sublayers if the layer is a group
if "layers" in layer:
print(f"Processing sublayers of group layer: {layer.get('title', 'Unnamed Layer')}")
process_layers(layer["layers"])
# Step 3: Process all layers, including those within group layers
process_layers(webmap.layers)
# Step 4: Save the updated Web Map
webmap.update()
print("All attribute expressions, fields lists, and text boxes removed, titles updated, and Arcade content added as a text element.") When I apply the below in an Arcade content section, the hyperlinks work. Whereas if I do it in an Attribute Expression and Text content, everything but the hyperlink works. var fieldsToExclude = ["OBJECTID", "SHAPE", "LAYERNAME", "GLOBALID", "SHAPE.STAREA()", "SHAPE.STLENGTH()", "CREATED_USER", "CREATED_DATE", "LAST_EDITED_USER", "LAST_EDITED_DATE", "LASTMODBY", "LASTMODDATE", "LASTSYNDATE"];
var content = "";
var seenUrls = {};
// Function to format URL fields
function formatURL(label, value) {
return "<b>" + label + ":</b> <a target='_blank' href='" + value + "'>Click here for more info.</a><br/>";
}
// Ensure all fields are available
Expects($feature, "*");
// Get the schema of the feature's layer
var schemaDict = Schema($feature);
var fieldsArray = schemaDict["fields"];
// Function to get the alias of a field
function getFieldAlias(fieldName) {
for (var j = 0; j < Count(fieldsArray); j++) {
var fieldDict = fieldsArray[j];
if (fieldDict['name'] == fieldName) {
return fieldDict['alias'];
}
}
return fieldName; // Fallback to field name if alias is not found
}
// Function to format dates as mm/dd/yyyy
function formatDate(dateValue) {
var date = Date(dateValue);
return Text(date, "MM/DD/YYYY");
}
// Function to get domain description
function getDomainDescription(fieldDict, value) {
// First, ensure that the domain key exists and is not null
if (HasKey(fieldDict, "domain")) {
var domain = fieldDict["domain"];
if (domain != null && HasKey(domain, "codedValues")) {
for (var k = 0; k < Count(domain["codedValues"]); k++) {
var codedValue = domain["codedValues"][k];
if (codedValue["code"] == value) {
return codedValue["name"];
}
}
}
}
return value; // Fallback to original value if no domain or match is found
}
// Iterate over each field in the schema to respect the field order
for (var i = 0; i < Count(fieldsArray); i++) {
var fieldDict = fieldsArray[i];
var fieldName = fieldDict["name"];
var alias = fieldDict["alias"];
var value = $feature[fieldName];
// Exclude certain fields and check if value is not empty
if (IndexOf(fieldsToExclude, Upper(fieldName)) == -1 && !IsEmpty(value) && Upper(Text(value)) != "NULL") {
// Check if the field value is a URL and format accordingly
if (Upper(Left(Text(value), 7)) == "HTTP://" || Upper(Left(Text(value), 8)) == "HTTPS://") {
if (!HasKey(seenUrls, value)) {
content += formatURL(alias, value);
seenUrls[value] = true;
}
} else if (fieldDict.type == "esriFieldTypeDate") {
// Format date fields
content += "<b>" + alias + ":</b> " + formatDate(value) + "<br/>";
} else if (HasKey(fieldDict, "domain") && fieldDict["domain"] != null) {
// Use domain description if available
var domainDescription = getDomainDescription(fieldDict, value);
content += "<b>" + alias + ":</b> " + Text(domainDescription) + "<br/>";
} else {
content += "<b>" + alias + ":</b> " + Text(value) + "<br/>";
}
}
}
return {
type: 'text',
text: content // this property supports HTML tags
};
... View more
08-16-2024
12:55 PM
|
1
|
2
|
1331
|
|
IDEA
|
Adding a filter with checkboxes (like you can in Excel) would help manage content in AGOL\Portal. The use came when I was trying to filter on an owner, and there was no option.
... View more
08-16-2024
07:12 AM
|
3
|
0
|
368
|
|
POST
|
On version 1.15, I am trying to download an application. When doing so, I get an error that states "Failed to load" and the file does not download. Has anyone else had this happen?
... View more
08-15-2024
12:40 PM
|
0
|
4
|
1458
|
|
POST
|
After seeing some related articles below after I posted this question, it resolved showing the field alias instead of the field name. Below is the updated code. I am still trying to have it show the fields in published order. https://community.esri.com/t5/arcgis-online-questions/issue-with-arcade-expression-in-popup-fields-only/m-p/1502708#M60087 https://developers.arcgis.com/arcade/function-reference/feature_functions/#expects var fieldsToExclude = ["OBJECTID", "SHAPE", "LAYERNAME", "GLOBALID", "SHAPE.STAREA()", "SHAPE.STLENGTH()", "CREATED_USER", "CREATED_DATE", "LAST_EDITED_USER", "LAST_EDITED_DATE", "LASTMODBY", "LASTMODDATE", "LASTSYNDATE"];
var content = "";
var seenUrls = {};
// Function to format URL fields
function formatURL(label, value) {
return "<b>" + label + ":</b> <a target='_blank' href='" + value + "'>Click here for more info.</a><br/>";
}
// Ensure all fields are available
Expects($feature, "*");
// Get the schema of the feature's layer
var schemaDict = Schema($feature);
var fieldsArray = schemaDict["fields"];
// Function to get the alias of a field
function getFieldAlias(fieldName) {
for (var j = 0; j < Count(fieldsArray); j++) {
var fieldDict = fieldsArray[j];
if (fieldDict['name'] == fieldName) {
return fieldDict['alias'];
}
}
return fieldName; // Fallback to field name if alias is not found
}
// Iterate over each field in the schema to respect the field order
for (var i = 0; i < Count(fieldsArray); i++) {
var fieldDict = fieldsArray[i];
var fieldName = fieldDict["name"];
var alias = fieldDict["alias"];
var value = $feature[fieldName];
// Exclude certain fields and check if value is not empty
if (IndexOf(fieldsToExclude, Upper(fieldName)) == -1 && !IsEmpty(value) && Upper(value) != "NULL") {
// Check if the field value is a URL and format accordingly
if (Upper(Left(Text(value), 7)) == "HTTP://" || Upper(Left(Text(value), 8)) == "HTTPS://") {
if (!HasKey(seenUrls, value)) {
content += formatURL(alias, value);
seenUrls[value] = true;
}
} else {
content += "<b>" + alias + ":</b> " + Text(value) + "<br/>";
}
}
}
return {
type: 'text',
text: content // this property supports HTML tags
};
... View more
08-08-2024
01:38 PM
|
0
|
0
|
776
|
|
POST
|
In migrating applications from WAB to Ex Builder, I am configuring pop ups via Arcade. The idea of the code below is to not display the fields in "fieldsToExclude", then display all other fields in every layer for the webmap using the same code and hyperlink when applicable. The issue I have been having is I cannot find a way to have the pop ups display the field alias, where it is only displaying the field name. The second issue is that the pop up is not displaying the fields in order of how the service is published. // General and URL Fields Formatting
var fieldsToExclude = ["OBJECTID", "SHAPE", "LAYERNAME", "GLOBALID", "SHAPE.STAREA()", "SHAPE.STLENGTH()", "CREATED_USER", "CREATED_DATE", "LAST_EDITED_USER", "LAST_EDITED_DATE", "LASTMODBY", "LASTMODDATE", "LASTSYNDATE"];
var content = "";
var seenUrls = {};
// Function to format URL fields
function formatURL(label, value) {
return "<b>" + label + ":</b> <a target='_blank' href='" + value + "'>Click here for more info.</a><br/>";
}
// Iterate over each field in the $feature
for (var field in $feature) {
var value = $feature[field];
var alias = field; // Use the field name as a fallback alias
// Exclude certain fields and check if value is not empty
if (IndexOf(fieldsToExclude, Upper(field)) == -1 && !IsEmpty(value) && Upper(value) != "NULL") {
// Check if the field value is a URL and format accordingly
if (Upper(Left(value, 7)) == "HTTP://" || Upper(Left(value, 8)) == "HTTPS://") {
if (!HasKey(seenUrls, value)) {
content += formatURL(alias, value);
seenUrls[value] = true;
}
} else {
content += "<b>" + alias + ":</b> " + Text(value) + "<br/>";
}
}
}
return {
type: 'text',
text: content // this property supports HTML tags
};
... View more
08-08-2024
12:27 PM
|
0
|
1
|
805
|
|
IDEA
|
@Jianxia , do you know if this request is in the roadmap at all? I am encountering this limitation migrating from WAB to EB.
... View more
08-01-2024
02:43 PM
|
0
|
0
|
3075
|
|
POST
|
Thank you @GeoJosh , that helps explain things. You are right, our metrics are not that low from 100.
... View more
07-23-2024
08:32 AM
|
0
|
0
|
1529
|
|
POST
|
I am working on a script that will create a Vector Tile Package from ArcGIS Pro and publish to Portal. In my testing portal environment, it functions as expected. When I switch the Portal URL, ItemIDs, etc to my production Portal, I get the below error. ERROR - Error updating item PortalItemID: ('Failed to create Vector Tile Package MapName: Item with this filename already exists. [itemId=PortalItemID]\n(Error Code: 409)', None) Does anyone have any suggestions on what might cause this behavior to exist in one instance of Portal but not another? The environment is ArcGIS Enterprise 11.2.
... View more
07-18-2024
01:59 PM
|
0
|
3
|
1189
|
|
POST
|
In addition, there is a similar pattern with the metric "connectivity - arcgis_server_discover (%)"
... View more
07-16-2024
08:32 AM
|
0
|
0
|
1613
|
|
POST
|
ArcGIS Monitor was deployed to monitor one of our ArcGIS Server machines about 3 months ago. There is one alert that has been maxed out or nearly maxed out since deployment titled "Connectivity - arcgis_server_metrics (%)". We deployed on 4/24/24, and it has been consistent since. Does anyone else have this appear as an alert consistently or have any tips? The metrics reference did not have much info on this. We are at Monitor version 2023.3.1.
... View more
07-16-2024
08:26 AM
|
0
|
4
|
1617
|
|
IDEA
|
In the latest update of AGOL, the measure tool and the my location tool looks to be its own widgets to add to a widget controller now. How long is it until they push features from AGOL EB to EB Developer?
... View more
06-27-2024
03:24 PM
|
0
|
0
|
3397
|
|
POST
|
I updated the Node.js version to the V18 after looking at the supported version table. It looks like the fix relates to this article by using the below code before npm ci. npm config set strict-ssl false
... View more
06-27-2024
09:55 AM
|
1
|
1
|
3293
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | Monday | |
| 1 | Monday | |
| 1 | Monday | |
| 2 | a week ago | |
| 1 | 3 weeks ago |
| Online Status |
Offline
|
| Date Last Visited |
Friday
|