|
DOC
|
@MelissaJohnson can you share the service to a Group and invite my AGOL account, jskinner_rats?
... View more
12-13-2023
05:29 AM
|
0
|
0
|
25984
|
|
POST
|
@aydemiremrah I don't have much experience with JavaScript, but if I were doing this in python, I would store the username/password in a secure config file that the script would call. The script would retrieve the username/password and generate the token.
... View more
12-08-2023
05:55 AM
|
0
|
0
|
3131
|
|
DOC
|
@AbiDhakal try the steps outlined in this document first. If for some reason it does not work, restore your snapshot. You can then update the existing data store connection with a SDE connection file pointing to the new SQL instance: Your services will redirect to this new SQL instance at this point. However, updating the existing data store connection will not update the workspace information when you click on this option for the service. Though, it is in fact pointing to the new SQL instance.
... View more
12-08-2023
05:52 AM
|
0
|
0
|
28764
|
|
POST
|
@Iguillen_abt if you have ArcGIS Server, one option would be to publish as an ArcGIS Server service rather than an ArcGIS Online hosted feature service. An ArcGIS Server service should maintain the maplex labeling.
... View more
12-08-2023
05:27 AM
|
2
|
1
|
4118
|
|
DOC
|
@AbiDhakal that only applies if you update the existing Database Data Store connection with a new SDE connection file that is pointing to the new SQL instance.
... View more
12-08-2023
05:23 AM
|
0
|
0
|
28780
|
|
POST
|
Hi @aydemiremrah, You have limited functionality with the token generated from the developers page. You will want to generate a token using the generateToken method using a username/password.
... View more
12-08-2023
03:57 AM
|
1
|
3
|
3153
|
|
DOC
|
@AbiDhakal that was my mistake, you do not need to create a WebGISDR backup. If you have snapshots of the server, you'll be good.
... View more
12-08-2023
03:53 AM
|
0
|
0
|
28798
|
|
DOC
|
@AbiDhakal, That should be it. If possible, create snapshots of your servers after the WebGISDR is restored. If there is an error, you can easily roll back. Also, if for some reason the script continues to fail, you can update your existing data store connections with the new .sde connection file. The only caveat of this is that the old SQL instance will still show in Server Manager when looking at the workspace info.
... View more
12-07-2023
09:46 AM
|
0
|
0
|
28842
|
|
DOC
|
@BBarbs, @PeterKnoop is correct, I should have used the objectIdField property for the layer. The code above has been updated to use this. Give that a try and see if you get the same error.
... View more
12-07-2023
09:35 AM
|
0
|
0
|
26286
|
|
POST
|
Hi @Josh-R, Instead of an overwrite, try a truncate/append: https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using/ta-p/904457
... View more
12-04-2023
04:01 AM
|
0
|
0
|
1635
|
|
DOC
|
@Moi_Nccncc take a look at the Track Idle Detector. This may provide a solution for you.
... View more
12-01-2023
05:39 AM
|
0
|
0
|
3379
|
|
DOC
|
@MarceloMarques this is interesting, what is the workflow to change an ArcGIS Server service data source using Pro 3.2?
... View more
11-27-2023
01:40 AM
|
0
|
0
|
29032
|
|
DOC
|
Hi @ashleyf_lcpud, You could create a dictionary of the feature class paths and the layer index number for which they should update. Then, iterate through the dictionary. Ex: import arcpy, os, time, uuid
from zipfile import ZipFile
from arcgis.gis import GIS
import arcgis.features
# Overwrite Output
arcpy.env.overwriteOutput = True
# Variables
username = "jskinner_rats" # AGOL Username
password = "********" # AGOL Password
fc1 = r"C:\Projects\GeoNET\GeoNET.gdb\GPGGA" # Path to Feature Class 1
fc2 = r"C:\projects\GeoNET\GeoNET.gdb\FACILITY_LOCATIONS" # Path to Feature Class 2
fsItemId = "12eefd574f64456a8f82edee35084a6f" # Feature Service Item ID to update
featureService = True # True if updating a Feature Service, False if updating a Hosted Table
hostedTable = False # True is updating a Hosted Table, False if updating a Feature Service
layerIndex1 = 0 # Layer Index 1
layerIndex2 = 1 # Layer Index 2
disableSync = True # True to disable sync, and then re-enable sync after append, False to not disable sync. Set to True if sync is not enabled
updateSchema = True # True will remove/add fields from feature service keeping schema in-sync, False will not remove/add fields
# Start Timer
startTime = time.time()
# Create dictionary
dataDict = {}
dataDict[fc1] = layerIndex1
dataDict[fc2] = layerIndex2
# Function to Zip FGD
def zipDir(dirPath, zipPath):
'''Zip File Geodatabase'''
zipf = ZipFile(zipPath , mode='w')
gdb = os.path.basename(dirPath)
for root, _ , files in os.walk(dirPath):
for file in files:
if 'lock' not in file:
filePath = os.path.join(root, file)
zipf.write(filePath , os.path.join(gdb, file))
zipf.close()
# Create GIS object
print("Connecting to AGOL")
gis = GIS("https://www.arcgis.com", username, password)
for fc, layerIndex in dataDict.items():
# Create UUID variable for GDB
gdbId = str(uuid.uuid1())
print("Creating temporary File Geodatabase")
gdb = arcpy.CreateFileGDB_management(arcpy.env.scratchFolder, gdbId)[0]
# Export featureService classes to temporary File Geodatabase
fcName = os.path.basename(fc)
fcName = fcName.split('.')[-1]
print(f"Exporting {fcName} to temp FGD")
if featureService == True:
arcpy.conversion.FeatureClassToFeatureClass(fc, gdb, fcName)
elif hostedTable == True:
arcpy.conversion.TableToTable(fc, gdb, fcName)
# Zip temp FGD
print("Zipping temp FGD")
zipDir(gdb, gdb + ".zip")
# Upload zipped File Geodatabase
print("Uploading File Geodatabase")
fgd_properties={'title':gdbId, 'tags':'temp file geodatabase', 'type':'File Geodatabase'}
fgd_item = gis.content.add(item_properties=fgd_properties, data=gdb + ".zip")
# Get featureService/hostedTable layer
serviceLayer = gis.content.get(fsItemId)
if featureService == True:
fLyr = serviceLayer.layers[layerIndex]
elif hostedTable == True:
fLyr = serviceLayer.tables[layerIndex]
# Truncate Feature Service
# If views exist, or disableSync = False use delete_features. OBJECTIDs will not reset
flc = arcgis.features.FeatureLayerCollection(serviceLayer.url, gis)
try:
if flc.properties.hasViews == True:
print("Feature Service has view(s)")
hasViews = True
except:
hasViews = False
if hasViews == True or disableSync == False:
# Get Min OBJECTID
minOID = fLyr.query(out_statistics=[{"statisticType": "MIN", "onStatisticField": "OBJECTID", "outStatisticFieldName": "MINOID"}])
minOBJECTID = minOID.features[0].attributes['MINOID']
# Get Max OBJECTID
maxOID = fLyr.query(out_statistics=[{"statisticType": "MAX", "onStatisticField": "OBJECTID", "outStatisticFieldName": "MAXOID"}])
maxOBJECTID = maxOID.features[0].attributes['MAXOID']
# If more than 2,000 features, delete in 2000 increments
print("Deleting features")
if (maxOBJECTID - minOBJECTID) > 2000:
x = minOBJECTID
y = x + 1999
while x < maxOBJECTID:
query = f"OBJECTID >= {x} AND OBJECTID <= {y}"
fLyr.delete_features(where=query)
x += 2000
y += 2000
# Else if less than 2,000 features, delete all
else:
print("Deleting features")
fLyr.delete_features(where="1=1")
# If no views and disableSync is True: disable Sync, truncate, and then re-enable Sync. OBJECTIDs will reset
elif hasViews == False and disableSync == True:
if flc.properties.syncEnabled == True:
print("Disabling Sync")
properties = flc.properties.capabilities
updateDict = {"capabilities": "Query", "syncEnabled": False}
flc.manager.update_definition(updateDict)
print("Truncating Feature Service")
fLyr.manager.truncate()
print("Enabling Sync")
updateDict = {"capabilities": properties, "syncEnabled": True}
flc.manager.update_definition(updateDict)
else:
print("Truncating Feature Service")
fLyr.manager.truncate()
# Schema Sync
if updateSchema == True:
# Get feature service fields
print("Get feature service fields")
featureServiceFields = {}
for field in fLyr.manager.properties.fields:
if field.type != 'esriFieldTypeOID' and 'Shape_' not in field.name:
featureServiceFields[field.name] = field.type
# Get feature class/table fields
print("Get feature class/table fields")
featureClassFields = {}
arcpy.env.workspace = gdb
if hostedTable == True:
for field in arcpy.ListFields(gdbTable):
if field.type != 'OID' and field.type != 'Geometry':
featureClassFields[field.name] = field.type
else:
for field in arcpy.ListFields(fc):
if field.type != 'OID' and field.type != 'Geometry' and 'Shape_' not in field.name:
featureClassFields[field.name] = field.type
minusSchemaDiff = set(featureServiceFields) - set(featureClassFields)
addSchemaDiff = set(featureClassFields) - set(featureServiceFields)
# Delete removed fields
if len(minusSchemaDiff) > 0:
print("Deleting removed fields")
for key in minusSchemaDiff:
print(f"\tDeleting field {key}")
remove_field = {
"name": key,
"type": featureServiceFields[key]
}
update_dict = {"fields": [remove_field]}
fLyr.manager.delete_from_definition(update_dict)
# Create additional fields
fieldTypeDict = {}
fieldTypeDict['Date'] = 'esriFieldTypeDate'
fieldTypeDict['Double'] = 'esriFieldTypeDouble'
fieldTypeDict['Integer'] = 'esriFieldTypeInteger'
fieldTypeDict['String'] = 'esriFieldTypeString'
if len(addSchemaDiff) > 0:
print("Adding additional fields")
for key in addSchemaDiff:
print(f"\tAdding field {key}")
if fieldTypeDict[featureClassFields[key]] == 'esriFieldTypeString':
new_field = {
"name": key,
"type": fieldTypeDict[featureClassFields[key]],
"length": [field.length for field in arcpy.ListFields(fc, key)][0]
}
else:
new_field = {
"name": key,
"type": fieldTypeDict[featureClassFields[key]]
}
update_dict = {"fields": [new_field]}
fLyr.manager.add_to_definition(update_dict)
# Append features from featureService class/hostedTable
print("Appending features")
fLyr.append(item_id=fgd_item.id, upload_format="filegdb", upsert=False, field_mappings=[])
# Delete Uploaded File Geodatabase
print("Deleting uploaded File Geodatabase")
fgd_item.delete()
# Delete temporary File Geodatabase and zip file
print("Deleting temporary FGD and zip file")
arcpy.Delete_management(gdb)
os.remove(gdb + ".zip")
endTime = time.time()
elapsedTime = round((endTime - startTime) / 60, 2)
print("Script finished in {0} minutes".format(elapsedTime))
... View more
11-15-2023
07:27 AM
|
0
|
0
|
26698
|
|
DOC
|
@DavidPike when a new user is added to Portal, you can add them immediately to the 'all users' group during the account creation steps. Another way would be to create a script that checks all named users in the Org and compare them to the named users in the 'all users' group. If a user is missing, the script could add the user to the group.
... View more
11-06-2023
04:35 PM
|
0
|
0
|
10674
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a month ago | |
| 4 | 05-07-2020 05:14 PM | |
| 1 | 03-25-2026 04:16 AM | |
| 1 | 03-16-2026 01:00 PM | |
| 1 | 12-22-2025 10:39 AM |
| Online Status |
Online
|
| Date Last Visited |
4 hours ago
|