POST
|
Has anyone resolved this issue or determined there is an open bug with ESRI ? It's February 2024 and it still persists - I'm unable to replace a vector tile layer from either the API using python or even directly from using the Replace Layer tool on the Details page of the vector tile layer on portal.
... View more
02-17-2024
03:24 AM
|
0
|
0
|
98
|
POST
|
I fixed up this script so it can be run autonomously from a CI tool. The script will connect to a Pro Project and look for a map that contains the feature layers to be overwritten. All the feature layers contained in this map and their service definitions must have already been published initially and hosted on AGOL. The script disables sync and unregisters replicas before overwriting the service definition file and existing feature service. The feature layers in the map may be grouped or ungrouped. Grouped layers will be published as a single feature service, same as the ungrouped layers. All service properties (sync, sharing, editing etc.) will remain the same as they originally were. The layer names in the Pro map must match the published feature layer names, so make sure the map is setup correctly in Pro. Thanks to Jake Skinner for getting this started in the right direction. import arcpy, os, time
from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
# Variables
prjPath = r"C:\PathToProProject\ProProject.aprx" # Path to Pro Project
map_name = 'Test Map Overwrite' # Name of map in Pro Project
portal = "https://www.arcgis.com" # AGOL
user = "username" # AGOL username
password = "password" # AGOL password
unregisterReplicas = True # True/False to unregister existing replicas
group_layer_names = []
ungrouped_layer_names = []
# Set Environment Variables
arcpy.env.overwriteOutput = 1
# Start Timer
startTime = time.time()
print(f"Connecting to AGOL")
gis = GIS(portal, user, password)
project = arcpy.mp.ArcGISProject(prjPath)
# Get the map in the project
map_obj = project.listMaps(map_name)[0]
# Iterate through all layers in the map and list the grouped layer names
for layer in map_obj.listLayers():
if layer.isGroupLayer:
group_layer_names.append(layer.name)
print (f"Grouped layer names: {group_layer_names}")
# Iterate through all layers in the map and list the ungrouped layer names
for layer in map_obj.listLayers():
if not layer.isGroupLayer:
# Check if the layer is part of any group layer
is_in_group = False
for parent_layer in map_obj.listLayers():
if parent_layer.isGroupLayer and layer in parent_layer.listLayers():
is_in_group = True
break
if not is_in_group:
ungrouped_layer_names.append(layer.name)
print (f"Ungrouped layer names: {ungrouped_layer_names}")
layer_list = ungrouped_layer_names + group_layer_names
print (f"Layers to be republished: {layer_list}")
# Loop through all the layers and get the feature layer and service definition ID's
for layer_name in layer_list:
# Filter the feature layers for an exact match and get the feature layer ID
fl_search_results = gis.content.search(query=f"title:{layer_name}", item_type="Feature Layer", sort_field='title', sort_order='asc')
fl_item = None
# Iterate through the search results to find the exact match
for item in fl_search_results:
if item.title == layer_name:
fl_item = item
break
if fl_item:
print(f"Found exact match for feature layer: {fl_item.title} (ID: {fl_item.id})")
else:
print(f"No exact match found for feature layer: {layer_name}")
# Filter the service definitions for an exact match and get the service definition ID
sd_search_results = gis.content.search(query=f"title:{layer_name}", item_type="Service Definition", sort_field='title', sort_order='asc')
sd_item = None
# Iterate through the search results to find the exact match
for item in sd_search_results:
if item.title == layer_name:
sd_item = item
break
if sd_item:
print(f"Found exact match for service definition: {sd_item.title} (ID: {sd_item.id})")
else:
print(f"No exact match found for service definition: {layer_name}")
# Local paths to create temporary content
sddraft = os.path.join(arcpy.env.scratchFolder, "WebUpdate.sddraft")
sd = os.path.join(arcpy.env.scratchFolder, "WebUpdate.sd")
sdItem = gis.content.get(sd_item.id)
#print (sdItem)
# Create a new SDDraft and stage to SD
print("Creating SD file")
arcpy.env.overwriteOutput = True
prj = arcpy.mp.ArcGISProject(prjPath)
mp = prj.listMaps(map_name)[0]
serviceDefName = sdItem.title
arcpy.mp.CreateWebLayerSDDraft(mp, sddraft, serviceDefName, 'MY_HOSTED_SERVICES', 'FEATURE_ACCESS', '', True, True)
arcpy.StageService_server(sddraft, sd)
# Reference existing feature service to get properties
fsItem = gis.content.get(fl_item.id)
#print (fsItem)
flyrCollection = FeatureLayerCollection.fromitem(fsItem)
existingDef = flyrCollection.properties
# Unregister existing replicas
if unregisterReplicas:
if flyrCollection.properties.syncEnabled:
print("Unregister existing replicas")
for replica in flyrCollection.replicas.get_list():
replicaID = replica['replicaID']
flyrCollection.replicas.unregister(replicaID)
# Overwrite feature service
sdItem.update(data=sd)
print("Overwriting existing feature service")
fs = sdItem.publish(overwrite=True)
# Update service with previous properties
print("Updating service properties")
flyrCollection.manager.update_definition(existingDef)
print("Clearing scratch directory")
arcpy.env.workspace = arcpy.env.scratchFolder
for file in arcpy.ListFiles():
if file.split(".")[-1] in ('sd', 'sddraft', 'png', 'xml'):
arcpy.Delete_management(file)
endTime = time.time()
elapsedTime = round((endTime - startTime) / 60, 2)
print(f"Script completed in {elapsedTime} minutes")
... View more
02-06-2024
12:43 PM
|
0
|
1
|
332
|
POST
|
A single service can have multiple layers, so this would not work in that scenario. True - but for the sake of reaping the benefits of using an automated publishing process like this, I'd make sure each layer in the map was published separately as a single service. This would be a special map only used for this purpose. The script will be run daily from a CI tool like Jenkins, so it needs to run completely autonomously on multiple layers.
... View more
02-02-2024
11:08 AM
|
1
|
0
|
375
|
POST
|
HI Jake - thanks so much that script works great! Pretty much does what I want to do, but I do have some suggestions that I think would make it even better if possible! Ideally this script would loop through a list of all the layers the map and republish each one of them. The values for the variables named serviceDefID and featureServiceID could be derived automatically from the existing hosted services by matching up the layer names in the Pro map with existing published service names (assuming that the map layer names must match the published feature service names for this to work). Since the real value here is to automate publishing, editing the script each time to change those variables and run it one at a time for each layer is probably going to take more time than just overwriting them manually. Of course you could create multiple scripts with different variables for each layer then run them all, but that's not ideal either. In a perfect world, you would have a Pro project with map that included all the layers to be overwritten and the script would process each of those layers without any intervention. The other thing is I would only update the Sharing properties if the value of shrGroups is not null. If it is null, then just leave the existing sharing properties intact.
... View more
02-02-2024
08:16 AM
|
0
|
0
|
385
|
POST
|
Would be great if someone could modify this script to include disable sync and unregister replicas before publishing takes place. I actually have attached a script that does this (attached) ... but not sure how/where to add it into the existing code example for automated publishing. from arcgis.gis import GIS
from arcgis.features import FeatureLayerCollection
from arcgis.features import FeatureLayer
import requests
# Connect to your ArcGIS Online organization
gis = GIS("https://www.arcgis.com","username","password")
token = gis._con.token
#Hosted feature layer names to disable sync and unregister all replicas
search_queries = ["Test Layer1", "Test Layer2"]
# Create an empty list to store the item IDs
item_ids = []
# Loop through each search query and get the corresponding feature services
for search_query in search_queries:
search_results = gis.content.search(query=search_query, item_type="Feature Service")
#print (search_results)
# Loop through each search result and append the item ID to the list
for search_result in search_results:
item_ids.append(search_result.id)
#print(item_ids)
# Loop through each item ID and unregister all replicas then disable sync
for item in item_ids:
flc = FeatureLayerCollection.fromitem(gis.content.get(item))
url = flc.url + "/unRegisterReplica?&replicaID=*&f=json&token="+token
#print (url)
response = requests.post(url)
flc.manager.update_definition({"syncEnabled": False})
message = "Successfully unregistered all replicas and disabled sync on: " + ", ".join(search_queries)
print(message)
... View more
02-01-2024
10:00 AM
|
0
|
2
|
400
|
POST
|
Why is Survey123 looking for a layer that shares a name with my instance_id?
... View more
10-10-2023
02:56 PM
|
0
|
1
|
210
|
IDEA
|
Categories are extremely helpful for organizing content on Portal (and AGOL). The problem is that since there is no way to make them required, more often than not they are left empty so the benefit of using categories to organize Portal content is not practical without constant/daily review and management by portal administrators. While training users and requesting that each new item should include a relevant category value, if that's not enforceable then it's not going to work - especially in a large organizations with many users creating content. The best solution would be to include a setting in Portal that would require a value in Categories if this setting was turned on. That way Portal Administrators could decide whether or not they wanted to make assigning Categories required or not.
... View more
06-20-2023
06:36 AM
|
4
|
1
|
328
|
BLOG
|
I get the blank screen too when trying to login (from Portal), and yes the Registered App is setup and the Re-direct URI added. That's not the problem. It's trying to load a localized language file that doesn't exist. in this line of code: https://assistant.esri-ps.com/locales/en-US/strings.json
... View more
01-04-2023
10:29 AM
|
2
|
0
|
3740
|
BLOG
|
The Info Summary widget in WAB is probably the most used widget in all of our web apps and dashboard themes. It's a quick, intuitive way for users to quickly identify and navigate to key points on a map. The existing features of the widget work well for our needs. In Experience Builder it would be ideal if this widget could also interact with other widgets. The Info Summary and Add Data widgets are the two key things currently missing from EB, and reason enough NOT to use EB until these have been added. Please feel free to contact me directly if you would like to see some live examples.
... View more
12-19-2022
04:45 AM
|
5
|
0
|
1854
|
IDEA
|
Why was this important feature removed? Please put it back!
... View more
08-17-2022
05:26 AM
|
0
|
0
|
593
|
IDEA
|
Hey all, This post is a long time coming. After speaking with a couple of Survey123 developers at the UC last week, I'm finally getting around to posting this idea to the community. TL;DR - Reorder fields in Survey123 based on an input set by the user. Survey123's success in my organization can be partially attributed to the ability to show & hide fields based on a condition set in Survey123 Connect. As an example, a lengthy maintenance inspection that differs from year to year can be consolidated into one mobile form. What was once 7 different forms on a different platform is now 1 form in Survey123. Less to manage, easier to maintain, and reliable offline capabilities. But I digress. In the effort to standardize this process, I have fielded feedback from multiple users asking to change the order of the fields in Survey123. Their reasoning is based in efficiency in the inspection process, as well as the ease of training others on how to perform the inspection. For context - this is related to electrical substation inspections. As I have come to find out, not all substations are created equal. Some have components that others don't have. Some have different layouts & different points of access. In an effort to streamline this process as best as possible, I have built relevant expressions to address the former, but have no good way of addressing the latter. Below, Substation A represents a custom field reordering, given one substation's needs. Substation B shows what the original survey looks like. Substation A Substation B In the spirit of consolidating this process (rather than create 30+ unique substation inspection surveys), I'm requesting a solution for reordering of fields in Survey123, conditionally based on user input. Thanks all, and special shout out to Barbara & Derek at the Survey123 booth(es) at the 2022 UC. @JamesTedrick for visibility @DavidForbuss1 had a similar request
... View more
07-22-2022
06:05 AM
|
3
|
1
|
251
|
POST
|
Are there any plans to include the Info Summary Widget from WAB in Experience Builder? Or has this been permanently replaced by the List Widget in Experience Builder?
... View more
07-22-2022
03:26 AM
|
1
|
2
|
463
|
POST
|
@ThomasPerriment1 Came here with the same exact question. Have you ran into any issues (performance or otherwise) since you implemented this? What order did you insert your readme sheet into the xlsform? Thanks in advance! -Mike
... View more
07-07-2022
07:21 AM
|
0
|
0
|
278
|
POST
|
Any changes? Still have lots of users submitting surveys without a username.
... View more
06-07-2022
11:29 AM
|
0
|
1
|
377
|
POST
|
In ArcGIS Pro 2.9.2 the process of converting BIM .ifc files by manually running these tools in order works fine: BIM File to Geodatabase Make Building Layer Create Building Scene Layer Content However trying to run these same tools in Model Builder fails. I contacted ESRI support and there is a known bug for this issue: BUG-000144891 Hopefully will be resolved soon, as running this process in Model Builder is much more efficient than doing this manually if you have multiple large BIM datasets to convert.
... View more
04-06-2022
03:14 AM
|
0
|
0
|
137
|
Title | Kudos | Posted |
---|---|---|
1 | 02-02-2024 11:08 AM | |
4 | 06-20-2023 06:36 AM | |
2 | 01-04-2023 10:29 AM | |
5 | 12-19-2022 04:45 AM | |
1 | 11-13-2019 08:33 AM |
Online Status |
Online
|
Date Last Visited |
6 hours ago
|