|
BLOG
|
I do something similar; default when survey123 form is submitted is already_emailed = NO. I just run the .py via task scheduler, kick out an email with a PDF report, then set already_emailed = YES via REST API. Here's some pseudo code, (no code bashing please ) def gentoken(username, password, referer, expiration=5): query_dict = {'username': username, 'password': password, 'expiration': str(expiration), 'client': 'referer', 'referer': referer, 'f': 'json'} tokenUrl = "https://ourportal.com/portal/sharing/rest/generateToken" tokenResponse = urllib.urlopen(tokenUrl, urllib.urlencode(query_dict)) token = json.loads(tokenResponse.read()) if "token" not in token: print token['messages'] exit() else: # Return the token to the function which called for it return token['token'] def applyUpdates(featureList,accessToken): #returns json string of POST reply payload = {'updates': json.dumps(featureList), 'token': accessToken, 'useGlobalIds': 'true', 'f': 'json'} query_string = urllib.urlencode(payload) q = "/applyEdits" url = baseURL + layerID + q req = urllib2.Request(url,query_string) resp = urllib2.urlopen(req) return json.loads(resp.read()) #URL of hosted feature service baseURL = 'https://ourportal.com/server/rest/services/Hosted/service_9ca0ddc438704f38970558c39a245ef1/FeatureServer/' #layer id in feature service we want to work with layerID = '0' #REST query string where = '"already_emailed" = ' + "'NO'" #REST query fields fields = '*' #lets get a token token = gentoken(USERNAME, PASSWORD, REFER) #construct REST query query = "/query?where={}&outFields={}&returnGeometry=true&f=json&token={}".format(where, fields, token) fsURL = baseURL + layerID + query fs = arcpy.FeatureSet() #load json string from server into feature set fs.load(fsURL) #convert json string from server into py dictionary pDict = json.loads(fs.JSON) #unecessary, but lets load our edited feat dict to a new list to send back to server newFeatList = [] for feat in pDict['features']: #returns list of features newDict = {} newDict['geometry'] = feat['geometry'] glid = feat['attributes']['globalid'] oid = feat['attributes']['objectid'] newDict['attributes']={'globalid':glid,'objectid':oid,'already_emailed':'YES'} #editing already_emailed here newFeatList.append(newDict)
... View more
07-31-2018
10:52 AM
|
0
|
0
|
18142
|
|
POST
|
type name label required relevant begin repeat freq_plot Freq Plots integer quad_id Quad ID yes begin repeat freq_plot_species Species List string-length(string(${quad_id}))>0 select_one species species_name Sci Name yes select_one livedead live_dead Live or Dead yes end repeat end repeat Basic nested repeat as shown above. Here's the survey form. The first record, Quad ID 1, has 2 inner repeat records, sp1-live and sp2-dead hence why you see the 2 of 2 count on the inner-repeat. This is the behavior one would expect. This is Quad ID: 2, the 2nd record. Here's a screenshot immediately after entering the Quad ID value. Notice how the inner-repeat is already pre-populated with 2 blank records. If the previous record, (Quad ID: 1) would of had 3 inner-repeat records, then this record would of also had 3 blank inner-repeat records and so forth. The biggest issue is when you arrow < to previous outer repeat records then try to navigate through the inner repeat records. You get validation errors because the blanks are not meeting the field required. After more testing, turns out that these blank records are ONLY created when you have a formula in the relevant column, as shown in the table at the top of this post. If that relevant formula is removed, then the blank records are not created. This is the same behavior in S123 Connect, S123 Windows, Android and iOS, all the latest versions. ESRI, is this expected or is this a bug? thanks.
... View more
07-31-2018
08:20 AM
|
2
|
10
|
5102
|
|
POST
|
Is there any way to skip a repeat entirely on a report template if the repeat record count is 0 ? thanks.
... View more
07-27-2018
07:55 AM
|
0
|
1
|
513
|
|
POST
|
I want to use an if condition to skip a question if the value of the question is Null, field type in Survey123 Connect is select_one. ${if select_one != "None"} ${if select_one != "Null"} ${if select_one != ""} Is this supported? thanks.
... View more
07-27-2018
07:47 AM
|
0
|
1
|
1275
|
|
POST
|
Same here, utcOffset isn't working. We have ArcGIS enterprise, survey was created/published using survey123 Connect. Trying to set utcOffset on a dateTime question so the output reports don't print UTC time, which is confusing to field crews reviewing the recently submitted data because it causes the date to sometimes be +1 day since PST is UTC-8.
... View more
07-27-2018
07:35 AM
|
0
|
0
|
1795
|
|
POST
|
type name label readonly calculation select_one shrub_species sp1 select species begin repeat shrub_intercepts enter intercepts text shrub_species selected shrub species yes ${sp1} integer int_start_cm start CM integer int_end_cm end CM end repeat Surveyors don't want to continually select a shrub_species inside the repeat each time they advance the repeat. They want select it 1 time (outside the repeat), then set multiple int_start_cm / int_end_cm values inside the repeat. Everything works as-expected until they want to switch the select_one shrub_species in the top dropdown box. If you back arrow < to the previously entered repeat records, they display the currently selected sp1 value, not the value that was selected when they were added. Luckily, after submitting and syncing the data, the database displays the correctly selected sp1 value. Anyone have a workaround so that field staff can page backward through the repeat and see what sp1 value was set?
... View more
04-19-2018
01:53 PM
|
0
|
10
|
5073
|
|
POST
|
Confirmed on my end also. 1) I had a survey with start/end fields, tried to edit a different survey question and re-publish; result was the timeInterval error. 2) deleted the start/end fields, republished successfully. The re-publish wipped out the data due to schema changes, so now I had a feat. service with no data. 3) I then added the start/end fields back into the survey and re-published again; successful. So I have the start/end fields in the survey now, odd how the issue happens sometimes, not others.
... View more
03-09-2018
08:46 AM
|
0
|
0
|
4002
|
|
POST
|
I've done more troubleshooting since my post a couple of weeks ago. It seems to be a problem with repeats, and not anything to do with the underlying form xls file. I had a working, existing survey that was published to Portal/Server 10.6, the feat. service did not contain any data, it was blank. The survey consisted of 2 repeats, each with 2 text fields, nothing overly complicated. I then tried to add a single text entry outside of the repeats, republish, then encountered the timeinterval error. I had to delete the survey, form, service and folder from portal and start over. I first tried publishing a survey with just the repeats, same timeinterval error. I deleted everything and started re-publishing the survey one group at a time, every attempt to re-publish was successful. Every group of questions that were published were NOT repeats. I then added the 2 repeats, republished and everything worked. Really strange behavior and will likely be difficult to repro. But seems to be related to repeats, and re-publishing (editing) existing features services. Jon - Did your survey have atleast 1 repeat in it?
... View more
03-02-2018
09:40 AM
|
1
|
4
|
4002
|
|
POST
|
after a day of trial/error with attribute rules, I just discovered they are NOT enforced on downloaded maps in Collector. Since they are applied at the database level, you don't get the validation error until you sync the offline data. Even worse is that since the db won't allow the features to be written (validation errors) the violating records are forever gone. Maybe you can dump them with iTunes from the runtime gdb, not sure. Glad I discovered this before deploying on a real project. Another gripe is that after attribute rules are added in ArcGIS Pro 2.1.1 you cannot work with the enterprise gdb in ArcMap any longer since it doesn't have the ability to work with attribute rules. Bummer. A new Collector update, that recognizes Arcade expressions is in dire need. Then, validation rules could be applied at the app level.
... View more
02-28-2018
02:02 PM
|
2
|
0
|
2587
|
|
POST
|
ArcGIS Pro 2.1, attribute rule, calculation contains this expression: Text(Now(), 'ddd D MMM Y') This gets inserted into the features attribute table, text field: Wed 28 Feb Y I also tried this expression: Text(Now(), 'ddd D MMM yyyy') This was the result: Wed 28 Feb yyyy Here's the workaround (messy): var fir = Text(Now(), 'ddd D MMM'); var sec = Text(Year(Now())); var arr = [fir,sec]; return Concatenate(arr,' ')
... View more
02-28-2018
11:09 AM
|
1
|
6
|
10613
|
|
POST
|
Using ArcGIS Pro 2.1, prior to publishing a feature service to Portal/server 10.6, I added a simple constraint attribute rule that requires a field to be populated. Triggering event is Insert. if (IsEmpty($feature.species)) { return false; } else{ return true; } **the insert trigger makes online editing on a portal webmap impossible. You try to create a new feature and the validation fails prior to the attribute box being displayed so you can enter a value. Is this the expected behavior? **in Collector online mode, your allowed to collect a feature, and the attribute box is displayed as should be. After you populated all the fields, I purposely skip the required field and try to Submit the feature. I get a popup saying a field is required, the options on the popup are: Cancel / Retry. Hitting Retry doesn't work, obivously because the attribute value is still missing. Hitting Cancel deletes the draft feature and all attributes your had previously entered. Is this the expected behavior? Too bad the Cancel option doesn't return you to the previously completed attribute popup where you can correct the required entries....
... View more
02-28-2018
09:20 AM
|
0
|
0
|
539
|
|
POST
|
A1) Portal and server are federated, using built-in portal users/roles. Portal and datastore are on seperate VMs, guest OS is Ubuntu Server 16.04. Server and web adaptor are on the same VM, guest OS is Win Server 2012 R2. A2) Problematic log is attached. I deleted most of the domain records, they were lengthy. A3) Advanced template, single question publishes fine, no issue. Following A3: I opened the 2 .xls files side-by-side. I started copying single rows from the problematic .xls (Form1), then pasted values into the advanced template .xls (Form2). I opened the Form2 folder, and deleted the .itemInfo file In portal, I deleted the Survey-Form2 folder I republished Form2. Repeat this sequence for each new row added from Form1 to Form2. I got to the end of the survey, no errors in publishing!!! There must have been an issue with the Form1 .xls file. thanks.
... View more
02-18-2018
05:45 AM
|
0
|
1
|
2014
|
|
BLOG
|
thanks for the inspiration! I did something very similar, but created a PDF via XML/XSLT. survey123 sets ${already_emailed} = 'NO' by default query hosted feat. service for already_emailed = 'NO', return FeatureSet (bummer how this doesn't contain domains) via REST query domain info for each field via REST: /service_1232/FeatureServer/layerID logged BUG-000111606, queryDomains doesn't work for hosted feat. services set already_emailed = 'YES' via REST: /applyEdits open template XML file, loop over featureSet. Populate fields, use XML attributes to specify field has domain/not. style XML file using XSLT template via Etree module. This exports an .html file Convert .html to .pdf via pdfkit module Email PDF report to project manager via cronjob Best part is that all we have to do is point this .py to a new hosted feat. service (survey123 database) and it will start firing off new reports based on any fields!
... View more
02-17-2018
01:04 PM
|
0
|
0
|
18142
|
|
POST
|
I cannot publish my survey to enterprise 10.6. I get the following error, anyone ever see this before? JSONobject["timeInterval"] not found. Error code 500. I tried removing the type=time fields from the survey, same result. confirmed that I can publish hosted feat. service in portal logged in as site admin. thanks!
... View more
02-17-2018
12:28 PM
|
0
|
6
|
2597
|
|
POST
|
FYI: the solution is to convert to json string, then encode that payload = {'updates': json.dumps(featureList), 'token': accessToken, 'useGlobalIds': 'true', 'f': 'json'} query_string = urllib.urlencode(payload) req = urllib2.Request(url,query_string) resp = urllib2.urlopen(req)
... View more
01-19-2018
02:23 PM
|
1
|
0
|
1319
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 3 weeks ago | |
| 1 | 05-02-2024 04:44 PM | |
| 1 | 11-04-2025 11:45 AM | |
| 1 | 10-31-2025 06:53 AM | |
| 1 | 02-06-2019 06:41 AM |
| Online Status |
Offline
|
| Date Last Visited |
2 weeks ago
|