This will particularly be useful for the back-end, since one cant always be on desk to see updates in Operations Dashboard or the main Web Map.
Thank you Jake.
Just in case the one feature service fields had an email content, can the script be written to pull the "from" as the email in the fields ?
Get Outlook for Android<https://aka.ms/ghei36>
Yes, you could update the parameters to include this field, assign the field value to a variable, and then pass this variable to the e-mail section. I have not tested this, but something like below:
# Query service and check if created_date time is within the last hour
emailList = []
params = {'f': 'pjson', 'where': "1=1", 'outfields' : '{0}, {1}, {2}'.format(uniqueID, dateField, emailField), 'returnGeometry' : 'false', 'token' : token}
req = urllib2.Request(URL, urllib.urlencode(params))
response = urllib2.urlopen(req)
data = json.load(response)
for feat in data['features']:
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:
oidList.append(feat['attributes'][uniqueID])
emailList.append(feat['attributes'][emailField]
print(oidList)
# Email Info
FROM = fromEmail
TO = [emailList]
SUBJECT = 'New Features Added'
TEXT = "Features with {0}s {1} were added.".format(uniqueID, oidList)
Thank You Jake.
This was really helpful.
I have the python script written.
After customizing the code lines what's the next step to get this up and running ?
You can set up Windows Task Scheduler to execute the script at a given interval:
Scheduling a Python script to run at prescribed times—Help | ArcGIS Desktop