Can GeoForms be configured to send a notification mail (to the administrator) when a feature is submitted ?

1157
5
06-26-2017 09:18 AM
RogerKayumba1
New Contributor II

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. 

Tags (1)
5 Replies
JakeSkinner
Esri Esteemed Contributor

Hey Roger,

Take a look at the following document:

https://community.esri.com/docs/DOC-10163 

RogerKayumba1
New Contributor II

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>

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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)
rogerkayumba
New Contributor

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 ?

0 Kudos
JakeSkinner
Esri Esteemed Contributor

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