Select to view content in your preferred language

Survey123 Tricks of the Trade: Editing records in a web form

84330
155
05-23-2019 05:34 PM
IsmaelChivite
Esri Notable Contributor
18 155 84.3K

[Updated November 30, 2021]

 

 

Today we will explore how you can edit existing records using the Survey123 web app. The idea is quite simple, we will populate the contents of a Survey123 form using an existing record from a feature layer and let users update (edit) that information. When working this way, the submit button in the survey will update an existing record, as opposed to creating a new one.

This technique for editing data in a web form be quite handy. You can use it for example to let people review and modify existing submitted data, or to simply let them finish an uncompleted form. You can also incorporate web forms into QA/QC and data validation workflows.

 

The Basics

 

Editing of existing data in a web form is possible through the use of Survey123 web app URL parameters. If you are not familiar with that, I strongly suggest you read the https://community.esri.com/groups/survey123/blog/2019/02/06/survey123-tricks-of-the-trade-web-form-u... first.

 

Here is an example:

https://survey123.arcgis.com/share/1cb28b212b5542acbbdbaa35feba0765?mode=edit&globalId=fb364524-e523...

Note the two URL parameters:

 

  • globalId=fb364524-e523-4f5d-9174-3def4bd21086, this parameter loads the record in your feature layer with the record  with globalId fb364524-e523-4f5d-9174-3def4bd21086 into your form. Of course, you can replace the globalId with the specific value of the feature you want to load.
  • mode=edit, puts the web form in edit mode. This essentially ensures that when the user hits the submit button, the current record is updated. If the mode is not set to edit, the form will create a new record when submitted, even if the form was initialized with data from a particular record.

 

URL parameters are case sensitive. For example: globalId is not the same as GlobalID or globalID. If you see that your form is not loading the record you want, double check the spelling of the parameter, and also ensure the globalId you are trying to load exists.

 

From a practical perspective, the technique described above is useless unless you somehow present a ready-to-use link (URL) to the end user; A link that already includes the appropriate globalId to edit. Do not expect end users to modify that globalId manually in the web browser URL address!  I will next describe three scenarios to illustrate how you could apply this technique.

 

Launching an edit web form from a feature popup

 

Our first scenario allows users to navigate a map, and launch an edit web form from the popup of an existing record. The key is to customize the feature layer popup so it dynamically generates the correct URL to launch the survey. Once the popup is configured, you can use the web map within the ArcGIS Map Viewer, custom Web AppBuilder apps, Explorer for ArcGIS and any app that supports web maps.

 

Here is a brief step by step guide to configure your popups:

 

  1. Using the ArcGIS map viewer, add your survey feature layer (or hosted feature layer view) into a web map.
  2. Open the configure popup dialog for your survey feature layer.
  3. In the popup contents section, select a custom attribute display.
  4. Add the URL of your web form into the attribute display. Then add the mode and globalId parameters.
  5. Dynamically populate the globalId parameter using the globalId field from your feature layer.
  6. Use the full web form URL with its parameters to create a link.
  7. Save the popup and test it out.

 

Embedding an edit web form within Operations Dashboard for ArcGIS

 

The idea with this one is to add an embedded content element within the dashboard, and configure it to display your web form.  The URL of the web form will include the mode parameter set to edit and the globalId will be dynamically populated.  Using a filter action triggered by other element within the dashboard, such as a list, the embedded content element will refresh your web form with the relevant record to be edited.

 

At a high level, the steps are as follows:

 

  1. Set a refresh rate on a web map displaying your survey feature layer.
  2. Add your web map to a new dashboard and configure a list element to display survey records.
  3. Add an embedded content element. In the Data options, set the Type to Features and add the URL of your web form with the mode=edit  and globalId parameters. Make sure the globalId parameter is set to pull a value from the globalId column in the fields collection.
  4. Next configure a filter action on the list element and target your embedded content element.
  5. Click on a record in the list, and your web form in the embedded content element will display your record in edit mode.

 

For more details about this, check https://community.esri.com/groups/survey123/blog/2020/04/27/survey123-tricks-of-the-trade-embedding-... 

 

Including an edit web form link in an e-mail.

 

In this scenario, we will use a web hook to automatically send an e-mail to the user submitting the survey. This email will contain a link for the user to complete or make modifications at any time.  To do this you must be familiar with web hooks in general or with either Microsoft Flow or Integromat.   Like in the examples above, the trick is to be able to dynamically populate the globalId of the record you want to edit. Luckily enough, the payload of a Survey123 web hook includes information about the user submitting the data (if logged-in) as well as responses to questions in the survey. So as long as the user is logged-in or a specific question in the survey captures the contact e-mail, you can make this work.

 

Here are the high level steps:

 

  1. Create a new survey. If you plan to share your survey publicly, include an e-mail question and make it required. If  you plan to keep your survey secured, you will be able to get the e-mail from the logged in user's profile.
  2. Use Microsoft Flow or Integromat to automate e-mail notifications when your survey is submitted.  The globalId of the record submitted is included in the payload of the web hook. Simply add the globalId to the URL of your edit web form when you add the link in the body of your e-mail.

 

Here is some visual aid in case you are using Integromat.

 

Survey123 Integromat

 

If you are using Integromat or Zapier, the pattern is pretty much the same: use the webhook payload to retrieve the globalId of the submitted record and use if for your edit web form url.

Tags (2)
155 Comments
HECAdmin
Regular Contributor

I tried embedding the link to edit a survey in an operations dashboard but I get a 404 error when it tries to load. However, I can copy the URL out of the chrome developer tools, paste it in a new tab, and the survey will load. This does not happen when I am signed in as the survey owner though. Any ideas on why this is happening? My users are very much looking forward to this feature.

TexasMike
Occasional Contributor

Great post and very nice addition. Just tested manually creating the link and pasting it into a browser. Worked as expected with a form published from connect 3.2 and using parameter "&version=latest"

Continue to be impressed with every update, keep up the great work Survey123 team!

NickDierks1
Frequent Contributor

Is there a way to get the linked-to web form to honor a query on the repeat records? I followed the steps to embed an editable web form in Operations Dashboard, but ALL repeat records display for any given parent record, and the user has to scroll past all of them to get to the latest record to edit. I'm using the following in bind::esri:parameters, which doesn't seem to be applied in this embedded web form: allowUpdates=true query="${vStatus} != 'Abated'" orderBy=${Date_Inspected}

JamesTedrick
Esri Esteemed Contributor

Hi Nick,

Repeats are currently not supported in web form editing at this time.

DerrickWestoby1
Deactivated User

Great post, Ismael. It seems like you always put these things up two weeks before I go searching for a how-to on exactly what you're describing.  

The main thing I was hoping for was being able to edit records that are inside of a repeat, but it looks like James already answered that question and that it's not yet supported.  I'll keep my eyes out for that feature when/if it becomes available. 

Thanks again for all the development effort on S123. 

DerrickWestoby1
Deactivated User

Did you make sure to enable add/update features and include ?mode=edit in your URL?  

https://survey123.arcgis.com/share/{FEATURELAYERID}?mode=edit&objectId={objectid} 

The walkthrough above worked for me, and I just double checked to make sure new features weren't being added (even when changing values, including time & location attributes)

MaazaMekuria
Frequent Contributor

I have had a problem submitting data on a form that works perfectly in the Field App. But now I have been able to resolve the data discrepancy.  It seems to be a product of choice lists and calculations that was in several fields in the form.  Calculations still cause the form to behave differently than how it works in the Field App.

I changed the form by removing choice lists and calculations that are attached to fields and the submission goes through. I had to fiddle with form and create an alternate form used only for dashboard submission that is plain vanilla. 

I am using an existing feature service as submission feature layer for a form that uses polyline geometry features.  This dataset gets updated using a script based on data points from another survey.  Is there a restriction on the type of geometry (such as it was before S123 using only points) to bring into embedded survey123 form? (suvery123)  The geometry is not brought into the embedded survey form or the web form but shows up in the field app. There appears to be a glitch in the software when the  geometry is a polyline.  I can bring for edit the point data from a different survey even when it is part of a repeat. I can see the feature geometry if I use the Field (Mobile) App but it does not show in the browser at all, whether the form is embedded in the dashboard or in a regular browser. 

I am using S123 version 3.5 at the moment. Any explanation from one of the ESRI fellows? 

Thank you,     

DerrickWestoby
Frequent Contributor

Ismael - Is it possible to get some sort of post-submittal message time out or a button that says "Submit another record" on these things?  

They're working great when embedded in a dashboard, but I have to refresh the page to get the form to load again. 

MaazaMekuria
Frequent Contributor

Outside the dashboard I can see the correct repeats for the parent record when using the browser based Webform during an edit.  It also allows me to edit (I could delete and move etc) I am assuming it works the same within the dashboard. I did not submit the updated data but at least in the form it appears to allow editing. 

TikaAdhikari1
Deactivated User

CAUTION:

If the layer to be edited has related records, the related records will be deleted after editing it.

Is that an expected behavior?

BEFORE EDITING:

AFTER EDITING:

MaazaMekuria
Frequent Contributor

Hellp, Geizon, I was able to edit on data with repeats using the webform and it works as expected.  The repeats are still there and the edit worked as I was able to pull the data back.

I am not sure what version of S123 you are using.

If publishing from an XLSForm there is a requirement that "allowUpdates=true allowAdds=True query" be placed on the bind::esri:parameters column of the begin_repeat row.  Read it at http://doc.arcgis.com/en/survey123/desktop/create-surveys/xlsformrepeats.htm  

TikaAdhikari1
Deactivated User

Thank you for the input, Maaza.

My Form didn't have any repeats. (However, it had some records related to it)

I deleted all the repeats from the form and left only the parent layer because the repeats couldn't be edited anyway.

However, your comment made me realize it is necessary to keep the repeats in the form, even though they can not be edited. Your input was very helpful.

Thank you!!

Vince_ERAC
Regular Contributor

Not related to the new mode=edit functionality, but I'm unable to pass a url parameter to a select_one field with the 'autocomplete' appearance set. Is this a known limitation? If I remove the appearance setting, or change the field to text rather than select_one it works properly (but I would really like to maintain the 'autocomplete' appearance).

Vince_ERAC
Regular Contributor

Bit of an update on this, it looks like the value may actually be passing into the 'autocomplete' field but it isn't visible... Im now attempting the mode=edit functionality and I notice when the existing form opens none of the 'autocomplete' fields show up as populated, despite when submitting the survey they are in fact filled in.

Initially Im also having the same issue as mentioned above where after editing the existing survey I am losing all related records (the survey I am editing doesnt actually even contain related records, the survey is only for the base table).

JamesTedrick
Esri Esteemed Contributor

Hi Derrick,

The option to submit another record is available in the Web Designer's settings.

It's not fully documented yet, but you can use the 

autoRefresh=true

parameter in the URL to cause the form to reload after submittal (true will refresh after 3 seconds, otherwise provide the length of time in seconds)

MaazaMekuria
Frequent Contributor

I think i shared the discrepancy between how the survey form behaves in the Field App and the browser is causing complications implementing it within a dashboard earlier.  I am surprised that the username attributes are not accessible in the browser form, while they are visible in the (  property('username')) field app. 

Is there any reason why I am unable to retrieve the username data within the browser, and the dashboard embedded form.   The form has user security enabled, and every one has to login in order to access it.  I also can see on the top of the embedded form the username displayed. The login information should be available and I am wondering if there is something that I can do to retrieve the value.  the form uses username to perform validation checks against users. 

Form Embedded in a Dashboard

MaazaMekuria
Frequent Contributor

Hello, James:

Could you provide a snippet where, in  the URL scheme, the "autoRefresh=true" gets appended?  I tried to add it to the url schema after the mode=edit and it does not work.

DerrickWestoby
Frequent Contributor

Thanks James.  

The issue was resolved the following day without me changing a single thing?  The "Press here to submit again." option was there the  day after I made that posted.

JamesTedrick
Esri Esteemed Contributor

Hi Mike,

Which browser are you using?  I have a successful test of using an autocomplete field in edit mode.

Vince_ERAC
Regular Contributor

Hi James, thanks for the reply. I was able to resolve this issue as well. I was apparently using an out of date Survey123 Connect to publish (without having realized) – that seemed to be the issue.

Thank you.

Sent from Mail<https://go.microsoft.com/fwlink/?LinkId=550986> for Windows 10

JamesTedrick
Esri Esteemed Contributor

The pattern for URL schemes is:

<URL>?<param1>&<param2>&<param3>...

In the case of Survey123 form, this will look like:

https://survey123.arcgis.com/share/<FORM GUID>?autoRefresh=true

If the form was published before 3.5, you may also need to add version=latest (as autoRefresh was introduced with 3.5):

https://survey123.arcgis.com/share/<FORM GUID>?autoRefresh=true&version=latest

GeeFernando
Frequent Contributor

Love this functionality.

Especially - being able to edit/add images 

I too would like this functionality to be extended to editing repeats.

Thanks so much,

Gee

NicholasHumphrey
Emerging Contributor

I love this ability, but every time I click on a feature and my survey pops up, I cannot edit the feature.  when I do fill out the survey it creates a new object ID and places it at 0 lat & 0 Long.  Here is my code....<table style=" border-collapse: separate; border-spacing: 0px 0px; width: 100%; table-layout: fixed; margin: 0px -1px;">
<tbody>
<tr>
<td style="text-align: center; width: 100%; padding-bottom: 50px; padding-top: 50px">
<a href="https://arcg.is/0uvGXr?mode=edit&objectid={ObjectID}&amp;version=latest" style="background-color: #EB9F29;color: #FFFFFF;padding: 25px 10px;text-decoration: none;margin: 0px auto;width: 300px; display: block;text-align:center;valign:center" target="_blank"><font size="5" style="">Update Road Hazard</font></a>
</td>
</tr>
<tr>
<td style="text-align: center; width: 100%">
<a href="https://arcg.is/4iGDn?mode=edit&objectid={ObjectID}&amp;version=latest" style="background-color: #3BE81E;color: #FFFFFF;padding: 25px 10px;text-decoration: none;margin: 0px auto;width: 300px; display: block;text-align:center;valign:center" target="_blank"><font size="5" style="">Clear Road Hazard</font></a>
</td>
</tr>
</tbody>
</table>

Please help...

MaazaMekuria
Frequent Contributor

I am updating the post to say that I was able to change the code to obtain the "username" by directly using a username question in the type column and collect the variable instead of the "property('username')" calculation and that has worked very well.

 

Now what I really have a problem is that I can't limit access to the submit button to query a record but should have no submission privileges.  I have been struggling to stop submission by those who should not submitt at all.  Is there any way to stop the submission of records that are unauthroised based on the user account.  I tried every possible way but it seems the submit button is just ignorant of any restriction I set using required information etc that is behind the scene.  I don't want to allow user input, I have the logged account and the account that has privileges to edit and submit.  What else can I do to revent unauthorised submissions?

Another issue has come up and Nicholas below has experienced it, that if an unauthrised person submits, it just makes a new record with partial data from the form (not all data is written to the new record). . This is not very good and defeats the purpose of editing in the first place.  What can we do to mitigate this problem?  Help! 

MaazaMekuria
Frequent Contributor

I have an interesting problem. I setup Microsoft Flow as an aid to communication of Survey123 activity, when a submission is made from a form it triggers other actions. I find that the trigger is not activated if the form is embedded in an ESRI Operations Dashboard.  Is there any workaround this problem? 

Thank you,

SavannahWinstanley1
Occasional Contributor

Hi, 

When trying to add the embedded content to a dashboard, it will not let me use a feature layer by URL, instead of when I select that option it asks me to choose an existing layer from my content. Leaving it as a document embedded type disqualifies it from actions.

Is this able to be worked around? Also the functionality I'm looking for would be that anybody without signing in could open and edit the form. The sharing settings are set up to do that but sometimes it will ask to log in anyway?

Thanks for any insight you can provide!

JamesTedrick
Esri Esteemed Contributor

Hi Savannah,

The example shown in this blog includes the form dynamically changing based on which feature is selected in a list.  To do that, you need to have the embeddable content based on a feature; the feature service you want to edit must be a data source in the dashboard.

erica_poisson
Frequent Contributor

Hi,

I'm using the Operations Dashboard instructions and generally, the editing works great. One issue I've noticed is that the geopoint is not carried through from the original survey into the "edit mode" survey. This only happens when the geopoint is selected by the person completing the survey.

      For context - We have a question "is work to be completed located at a building?" If the person answers 'yes', they pick       a building from the list that appears, and the geopoint is populated with X/Y based on their selection. This works great in       "edit mode".  When they answer that question 'no', they get to enter their own geopoint. This is what does not get       preserved in "edit mode".

Is this expected? Is there a way we can get around this? We don't want to loose the location, just to update a few fields within the survey.

Thanks,

Erica

JamesTedrick
Esri Esteemed Contributor

Hi Erica,

Can you provide more information on how the calculation for the point is structured?

erica_poisson
Frequent Contributor

Hi James,

The calculation for the point is:

concat(substr(${Building_Name},0,10)," ",substr(${Building_Name},-10))

The survey is set up so that this point calculation takes affect if the answer to a previous question is met, and a location is selected from a select_one list. If the answer is not met, then the user can select a unique location on the list. It is the unique locations that are not carried through when editing the survey via edit mode.

I've added the portion of my XLS below where you can see this.

Thanks,

Erica

typenamelabelhintconstraintconstraint_messagerequiredrequired_messageappearancedefaultreadonlyrelevantcalculation
select_one request_typeRequest_TypeRequest Typeyesminimal compact
select_one yesnoWork_at_BuildingIs work to be completed located at a building?yeslikert
select_one building_nameBuilding_NameBuilding Name<i>Select the building's name from the list.</i>horizontal-compact${Work_at_Building} = 'Yes'
geopointWork_LocationWork Location<i>Select the location at which work needs to be completed.</i> yesconcat(substr(${Building_Name},0,10)," ",substr(${Building_Name},-10))
JamesTedrick
Esri Esteemed Contributor

Hi Erica,

Thanks for explaining in detail.  Based on this, I can see the behavior you are describing.  While I've noted this internally to fix, you may still want to file a support ticket with Esri so that this can be tracked and other customers attached if they are experiencing this issue.

BrittneyGibbons1
Regular Contributor

We are trying to edit existing records from a webmap using a Survey123 webform. We can open the form and pass the object id, but get the message "You cannot edit existing records since you are not Editor or the Owner." at the top of the form and none of the attributes from the database populate in the form. Any suggestions how we can resolve this error?

Thank you.

MaazaMekuria
Frequent Contributor

There was a setting in the webform that needed to explicitly request a trigger for edits that I missed and that took care of the problem. 

MaazaMekuria
Frequent Contributor

Brittney, check the permissions for the specific form to see if the user is allower to edit data.  We have no problems editing as long as the form and the underlying data security is properly assigned. That setting is in "Collaboration" on the survey123 editing page.

erica_poisson
Frequent Contributor

Hi James,

This is encouraging. Do you have any sort of timeline for when this will be corrected? I will also submit a ticket to lodge an official bug.

Best,

Erica

JamesTedrick
Esri Esteemed Contributor

Hi Erica,

Given that this was just diagnosed, we don't have a timeline yet.  Please submit the bug as it helps our tracking process.

erica_poisson
Frequent Contributor

For anyone interested in tracking this issue, it has been logged as BUG-000126498.

JeffreyEbner
Emerging Contributor

Forgive me if this is a basic question, but when I followed directions to embed the web edit form and link to a list in a dashboard I get an error, "Editing is not possible because the objectid parameter was not provided." I have  entered the correct parameters after the url -  ?mode=edit&objectid={ObjectId} but seem to be getting this error still?

HECAdmin
Regular Contributor

The I in the objectId parameter needs to be capitalized. Try "?mode=edit&objectId={ObjectId}"

JeffreyEbner
Emerging Contributor

Thank you for the reply, but now after capitalizing the i to I there is this error message?

Is there something that I'm missing?

JeffreyEbner
Emerging Contributor

Got it to work! Thanks a bunch.

PamelaLandy
Regular Contributor

1. I am trying to point to my portal, but it is not possible  https://survey123.arcgis.com/?myportalUrl=https:%2F%2Fmyportalxxxxx.domain.us.%2Fmyportalxxxxx 


2. For the same case using the mobile app and survey connect 3.6 , what option do we have ? I refer to the modification of attributes without inserting a new point via survey app.

JamesTedrick
Esri Esteemed Contributor

Hi Pamela,

1. The correct parameter name is portalUrl, not myportalUrl

2. The field app supports updating existing records via the Inbox - see Prepare for editing existing survey data—Survey123 for ArcGIS | Documentation .

BrandonSaunders1
Occasional Contributor

I'm trying to configure this to work in a web map I'm accessing through the Explorer app.  When I click on a record in Explorer, it takes me to the survey but then I get an error that says "The feature is not available.  The creation date field cannot be found in the feature service."  I've verified I can see the creation date field in the feature service.  Any thoughts?

GarethBaker1
Frequent Contributor

Hi James,

Just wondering if the ability to edit an existing record via the URL scheme will ever make it into the field app? I know the option is there to do via the inbox but our users are struggling with this as a workflow because they use Collector to find their assets that need inspecting.  You mentioned over in this thread that it was something you planned to support but just wondered if there was a timescale?

Thanks

Gareth

JamesTedrick
Esri Esteemed Contributor

Hi Brandon,

Can you open a support incident with Esri Support?  I think we would need both the feature service information as well as the form to be able to diagnose what is occurring.

JamesTedrick
Esri Esteemed Contributor

Hi Gareth,

Yes, this is a feature we do plan to support within the field app; however, I cannot provide a timeline for implementation yet.

DanielSattler
Emerging Contributor

I am getting this same error here.  What did you do to finally resolve it?

Does the ObjectID have to be used for this to work, or can I use a different field setup this same way (to edit an existing feature)?  For example an "AssetID" field?  

I tried to use the AssetID field and I receive this objectID parameter message above, not sure if it's not possible or if I have it structured wrong.

EDIT: I was able to get this working by using the ObjectID and edit existing objects- I just created a new survey, started over.  

Still curious if you can use something other than ObjectID though. 

Any thoughts on this? 

Next step is to get this working with related records.....

LaurenLochstampfor
Observer

I have been trying to use this workflow to edit a survey on our enterprise portal, but have not been successful. Is there a different format for the URL for enterprise portal based surveys?

JohnBrosowsky1
Emerging Contributor

Hi there -

The example is not working as described. The basics state "...if the mode is not set to edit, the form will create a new record when submitted, even if the form was initialized with data from a particular record".  However that is not the case.  If I remove mode or set it to any other value besides edit or view the survey form displays an error message. 

I would like to initialize my form from a particular record, but upon submission create a new record rather than updating the current record.  Is there a different value I should use for mode, or some other trick to it?

Thanks!

John