Allow users to edit their submitted data (without the Survey123 App)

1105
4
01-25-2022 02:57 PM
Status: Closed
Labels (2)
MatthewMuehlhauser
New Contributor III

I have a Survey123 survey embedded into a dashboard. It's a simple survey with just one ranking question. The survey is set up so that each user can only submit the survey one time, however; they are allowed to edit their submissions. When a user submits, they are taken to the Thank You page, but when they reload the page, they are taken to a "You've already taken this survey" page. 

Ideally, I would like the users to be able to edit their existing submission, but there doesn't seem to be a configurable way to set this up in Dashboard (Get user name --> search survey results for their record --> insert GlobalID into survey URL for embedded survey). Instead, since there is obviously a check going on to see if they've submitted, it would be nice if it would show the "You've already taken this survey" page text, but then include a "Would you like to edit your previous response?".

I mean, I've checked the box saying I want them to be able to edit their submissions, so that seems like it should be reasonable.

Tags (3)
4 Comments
jcarlson

It might be complicated, but I bet you could do this with a Data Expression somehow.

Are the editor tracking settings configured so that users can only see their own features? That might simplify things.

MatthewMuehlhauser

Ok, so I have a Data Expression now that returns the URL for the survey depending on whether the user has submitted a survey before or not, assuming that there should only be 0 or 1 records since they can only see their own, although myself I can see all so need to test that out first to make sure that is the case.

That being said, the Test button returns the expected URL result, however; the Data Expression itself has a warning next to it saying "Unable to Execute Arcade Script". I thought this might be due to the fact that it's not a feature, so I turned the result into a Feature with a URL attribute and a random Geometry, and it's still unable to be selected.

Aside from that though, I have the URL Expression, but how would I use the output to fill in the URL text box for the embedded content panel?

var url = 'https://survey123.arcgis.com/share/{Removed Survey ID}'
var editUrl = '?mode=edit&globalId='
var features = FeatureSetByPortalItem( Portal('https://www.arcgis.com'), '{Removed Item ID}', 0, ['GlobalID', 'Creator'], false );

var featureCount = Count(features)

var urlID = IIf(featureCount > 1, '{My Records Global ID}', IIf(featureCount < 1, null, First(features).GlobalID));

var finalURL = IIf(urlID != null, url + editUrl + urlID, url)

var pointJSON = {"x": -118.15, "y": 33.80, "spatialReference": { "wkid": 3857 } };
var pointGeometry = Geometry(pointJSON);

Feature(pointGeometry, 'survey_url', finalURL)

 

MatthewMuehlhauser

Realized that it needed to be a FeatureSet and not a Feature. Changed that and I got a working expression. And it was actually pretty easy to get it into the URL text box after that!

 

FeatureSet('{"fields":[{"alias":"URL","name":"URL","type":"esriFieldTypeString"}],"spatialReference":{"wkid":3857},"geometryType":"esriGeometryPoint","features":[{"geometry":{"spatialReference":{"wkid":3857},"x":-151.0063,"y":63.069},"attributes":{"URL":"' + finalURL + '"}}]}')

 

 

 

IsmaelChivite
Status changed to: Closed