|
DOC
|
@Michael_Wozniak I was able to get the script to work with the service you shared. Try the one below. It sends multiple e-mails instead of one e-mail with a list of OBJECTIDs for the features that were created. You will just need to update the username and password. import requests, json, datetime, time, smtplib, math
from datetime import timedelta
from email.mime.text import MIMEText
# Disable warnings
requests.packages.urllib3.disable_warnings()
# Variables
username = 'jskinner_CountySandbox' # AGOL Username
password = '*******' # AGOL Password
URL = 'https://services9.arcgis.com/8FOQ9nDvQJjqML1o/arcgis/rest/services/CitizenProblems_4ccc650e579c469697018f64006e9acc/FeatureServer/0/query' # Feature Service URL
dateField = 'CreationDate' # Date field to query
hoursValue = 1 # Number of hours to check when a feature was added
fromEmail = '[email protected]' # Email sender
toEmail = ['[email protected]'] # Email receiver(s)
smtpServer = 'smtp.esri.com' # SMTP Server Name
portNumber = 25 # SMTP Server port
# Function to send email
def sendEmail():
SUBJECT = 'Problem Reported'
TEXT = "{0} was created with status {1} and has been assigned to {2}".format(typeProb, status, assignedto)
smtpObj = smtplib.SMTP(host=smtpServer, port=portNumber)
msg = MIMEText(TEXT)
msg['Subject'] = SUBJECT
msg['From'] = fromEmail
msg['To'] = ", ".join(toEmail)
smtpObj.sendmail(fromEmail, toEmail, msg.as_string())
print("Successfully sent email")
smtpObj.quit()
# Generate AGOL token
try:
print('Generating Token')
tokenURL = 'https://www.arcgis.com/sharing/rest/generateToken'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'http://www.arcgis.com'}
r = requests.post(tokenURL, data=params, verify=False)
response = json.loads(r.content)
token = response['token']
except:
token = ''
# Return largest ObjectID
whereClause = '1=1'
params = {'where': whereClause, 'returnIdsOnly': 'true', 'token': token, 'f': 'json'}
r = requests.post(URL, data = params, verify = False)
response = json.loads(r.content)
try:
response['objectIds'].sort()
except Exception as e:
print("Error: {0}".format(e))
count = len(response['objectIds'])
# Query service and check if editDate time is within the last hour
if count < 1000:
params = {'f': 'pjson', 'where': "1=1", 'outFields' : '*', 'returnGeometry' : 'false', 'token' : token}
r = requests.post(URL, data=params, verify=False)
response = json.loads(r.content)
for feat in response['features']:
typeProb = feat['attributes']['probtype']
status = feat['attributes']['status']
assignedto = feat['attributes']['assignedto']
createDate = feat['attributes'][dateField]
createDate = int(str(createDate)[0:-3])
t = datetime.datetime.now() - timedelta(hours=hoursValue)
t = time.mktime(t.timetuple())
if createDate > t:
sendEmail()
... View more
07-30-2021
05:28 AM
|
0
|
0
|
15838
|
|
DOC
|
@Michael_Wozniakcan you share the service to an AGOL Group and invite my user account (jskinner_CountySandbox)? It looks like there are no new features added within the timeframe you're querying. The default in the code is 1 hour.
... View more
07-29-2021
05:35 PM
|
0
|
0
|
15846
|
|
POST
|
Hi @JulietK , Search for the word mapWidget. Within this section, replace the itemId with the item id of the new web map. I've had success with this, but not always. JakeSkinner_0-1627346256994.png
... View more
07-26-2021
05:37 PM
|
0
|
3
|
6012
|
|
POST
|
Hi Allison, You can find just about any course on udemy: https://www.udemy.com There's also one tailored for ArcGIS: https://www.udemy.com/course/design-web-maps-with-html-js-css-and-/
... View more
07-26-2021
05:19 PM
|
2
|
0
|
4465
|
|
DOC
|
@BB_GIS try the following: 1. Open the ExportWebMap.py in an IDE or text editor 2. Replace the updateDynElmSrc function (line 90) with the following: def updateDynElmSrc(result):
arcpy.AddMessage("updateDynElmSrc...")
p = result.ArcGISProject
m = p.listMaps()[0] #assuming for now that there is only one map in the current project
l = p.listLayouts()[0] #there is always only one layout in this case
#getting the source layer's cim path for the first feature layer in the map
lyr = None
for lyr in m.listLayers():
if lyr.name == 'Parcels':
layerName = lyr.name
lyr_uri = lyr.getDefinition('V2').uRI
arcpy.AddMessage("cim_path for " + layerName + " is " + lyr_uri)
for txtElm in l.listElements('TEXT_ELEMENT'):
arcpy.AddMessage("Original: textElement.text = '" + txtElm.text + "'")
txtElm.text = txtElm.text.replace('mapMemberUri=""', 'mapMemberUri="'+ lyr_uri +'"')
arcpy.AddMessage("Modified: textElement.text = '" + txtElm.text + "'") 3. In line 10 above, replace 'Parcels' with the name of the feature layer. 4. Republish the print service
... View more
07-26-2021
09:49 AM
|
0
|
0
|
31651
|
|
POST
|
@Joshua-Young unfortunately, it will not. See my comment from 06-16-2021.
... View more
07-26-2021
06:09 AM
|
0
|
2
|
6094
|
|
DOC
|
This tool will allow you copy an ArcGIS Online hosted feature service to an ArcGIS Enterprise hosted feature service. The ArcGIS Enterprise must have an ArcGIS Server instance federated and designated as a Hosting Server.
... View more
07-09-2021
06:58 AM
|
2
|
0
|
1857
|
|
IDEA
|
@MiguelMartinezYordan here is some code you can use to do this. The Pro project will require a single map and a single layout added. You can then update the # Variables section: import arcpy, os, sys
arcpy.env.overwriteOutput = 1
# Variables
geoTIFFDirectory = r"C:\GeoTIFFs"
gridIndex = r"C:\Data.gdb\GridIndex"
dpi = 300
proProject = r"C:\Projects\Export.aprx"
# Get count of gridIndex
totalNets = arcpy.GetCount_management(gridIndex)
count = int(totalNets.getOutput(0))
# Reference Pro Project and layout
p = arcpy.mp.ArcGISProject(proProject)
l = p.listLayouts()[0]
mf = l.listElements("mapframe_element")[0]
# Export GeoTIFFs
for feat in range(1, count + 1):
with arcpy.da.SearchCursor(gridIndex, ["SHAPE@"], f"OID = {feat}") as cursor:
for row in cursor:
extent = row[0].extent
geoTIFF = os.path.join(geoTIFFDirectory, f"PageID_{feat}.tif")
mf.camera.setExtent(extent)
cam = mf.camera
arcpy.AddMessage(f"Exporting {geoTIFF}")
mf.exportToTIFF(geoTIFF, resolution=int(dpi), world_file=True, geoTIFF_tags=True)
del cursor
# Delete reference to Project
del p geoTIFFDirectory = directory to store GeoTIFFs gridIndex = path to grid index feature class dpi = dpi of GeoTIFFs proProject = path to APRX file
... View more
07-07-2021
06:03 AM
|
0
|
0
|
5197
|
|
DOC
|
@LindseyStonecurrently this will only work with the visible content. You could filter by the OBJECTID of the water line service. For example, click on the feature you wish to show the information for and copy the OBJECTID from the pop-up, then use this OBJECTID in a filter.
... View more
07-06-2021
03:25 AM
|
0
|
0
|
31845
|
|
DOC
|
@akjones3 what version of the ArcGIS API for Python are you running? You can check by running the following: import arcgis
arcgis.__version__ JakeSkinner_0-1625152287135.png
... View more
07-01-2021
08:11 AM
|
0
|
0
|
64722
|
|
POST
|
Yes, ArcGIS Pro will need to be able to communicate with the License Manager server via port 27000. Are you able to telnet from the ArcGIS Pro server to the license manager server? Ex: telnet license.server.com 27000
... View more
06-16-2021
09:04 AM
|
1
|
2
|
6348
|
|
POST
|
Is the ArcGIS Pro client machine on the same network as the portal/license manager server? The ArcGIS Pro client will need to be able to access this server. See the below screen shot from the following link: GUID-A8E3A6DC-8D40-4B39-8621-8A25341D5196-web.png
... View more
06-16-2021
07:10 AM
|
1
|
1
|
6359
|
|
POST
|
@NeilEtheridge you could generate the token with the below code, which includes the expiration parameter. This value is in minutes, and the max is 15 days: import requests, json
# Disable warnings
requests.packages.urllib3.disable_warnings()
username = "portaladmin"
password = "********"
tokenURL = 'https://portal.esri.com:7443/arcgis/sharing/rest/generateToken/'
params = {'f': 'pjson', 'username': username, 'password': password, 'referer': 'https://portal.esri.com', 'expiration': 21600}
r = requests.post(tokenURL, data = params, verify=False)
response = json.loads(r.content)
token = response['token']
print(token)
... View more
06-09-2021
06:40 AM
|
2
|
2
|
3208
|
|
POST
|
@anilbaral99I always get cautious when overwriting a feature service. As an alternative, you may want to try the following script as a workaround: https://community.esri.com/t5/arcgis-online-documents/overwrite-arcgis-online-feature-service-using-truncate-and/ta-p/904457
... View more
06-07-2021
06:19 AM
|
0
|
1
|
4283
|
|
DOC
|
When sending an e-mail from an Input that is incrementally polling an ArcGIS Server service, one should be cautious when rebooting the GeoEvent server. Rebooting the server will cause the Poll an ArcGIS Server for Features input to start polling all features again. This will result in dozens, hundreds, or even thousands of e-mails sent if the Send An Email output is running. This document will walk you through how to prevent this from happening by executing a python script that will stop all, or specified, outputs at server shutdown. 1. If wanting to stop only a select number of GeoEvent outputs, you will need to obtain the names of each output. The name is a GUID that can be obtained from the GeoEvent Admin Directory. Ex: https://geoevent.esri.com:6143/geoevent/admin Once logged in, click on Outputs at the top, then click on the GeoEvent Output. The Name will be listed there: screen1.png Open the attached Stop All GeoEvent Outputs.py script. Under the # Variables section, set the stopAllOutputs to False and update the outputs with each name copied from the GeoEvent Admin Directory. Ex: screen2.png 2. If wanting to stop all GeoEvent outputs, set the stopallOutputs variable to True: screen3.png 3. Update the remaining variables in the python script. Below is an explanation of each. username = username to connect to GeoEvent Manager password = username’s password geoeventServer = fully qualified domain name of the server GeoEvent is installed on federated = specify True if GeoEvent is federated with Portal, specify False if GeoEvent is not federated with Portal portalServer = fully qualified domain name of the server Portal is installed on. This is only required if federated variable is set to True. This cannot be the DNS if using one stopAllOutputs = set to True to stop all outputs, set to False to stop a select amount outputs = list of output names to stop. This is only required if stopallOutputs variable is set to False 4. On the GeoEvent Server, open Local Group Policy Editor by going to Start > Run > gpedit.msc screen4.png 5. Navigate to Computer Configuration > Windows Settings > Scripts (Startup/Shutdown) screen5.png 6. Double-click Shutdown screen6.png 7. Under the Scripts tab click Add screen7.png 8. For Script Name browse to the python executable (python.exe) under the ArcGIS Server installation. Ex: C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3\python.exe 9. For Script Parameters enter the path to the Stop All GeoEvent Outputs.py python script screen8.png 10. Click OK and then OK again When the server is rebooted the python script will be executed and stop the GeoEvent outputs. After the server is started, GeoEvent will start polling all features in the ArcGIS Server service you have specified for the Poll an ArcGIS Server for Features inputs. However, since the outputs are not started you will not be sent any e-mails. Once the inputs are finished polling the ArcGIS Server services the Send An Email output(s) they are sending events to can be started. Now, an e-mail will only be sent on the next incremental update.
... View more
06-06-2021
06:59 AM
|
4
|
1
|
2580
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 07-08-2026 12:27 PM | |
| 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 |
Offline
|
| Date Last Visited |
Tuesday
|