Select to view content in your preferred language

Is it possible to send data back from Survey123 in a callback URL?

2360
16
05-26-2021 01:28 PM
DougBrowning
MVP Esteemed Contributor

After hours of trying I think I know the answer but I wanted to check.

I finally got a callback URL (that double encoding is lots of fun) to work once I switched to hardcoding the values.  There are no help samples of this.

Here is my sample hardcodeing the callback values and feature globalid

arcgis-survey123://?itemID=9269d29cfc994accb9c3739c556ee345&field:LOCAL_ID={LOCAL_ID}&field:GeoGUID={globalid}&callback=https%3A%2F%2Ffieldmaps.arcgis.app%3FitemID%3D60898699d9194370985ba5d1b88ac966%26referenceContext%3DupdateFeature%26featureSourceURL%3Dhttps%3A%2F%2Fservices1.arcgis.com%2FHp6G80Pky0om7QvQ%2Farcgis%2Frest%2Fservices%2FPFCRCTest4%2FFeatureServer%2F0%26featureID%3D431c51d1-2570-4677-a13e-4a42d582cf66%26featureAttributes%3D%257B%2522LOCAL_ID%2522%3A%2522testhardcode%2522%2C%2522FormGUID%2522%3A%2522hardid%2522%257D

But what I would like to do is pull a field back from 123.  I am doing this to link the forms in both directions.  I want to send back a guid that I generate in 122.

I have tried this (unencoded).  Just the callback part works from 123 so I got that part right and I can use 123 fields just fine.

arcgis-survey123://?itemID=9269d29cfc994accb9c3739c556ee345&field:LOCAL_ID={LOCAL_ID}&field:GeoGUID={globalid}&callback=https://fieldmaps.arcgis.app?itemID=60898699d9194370985ba5d1b88ac966&referenceContext=updateFeature&...${LOCAL_ID}%22,%22FormGUID%22:%22${FormGUID}%22%7D

I have a feeling that the callback URL is hard generated at the time of the call in Field Maps.  That means referencing a field in 123 with ${LOCAL_ID} makes no sense since you are in Field Maps at the time the URL is generated.  Am I right?

If I am in right is there any way to send data to 123 via a URL then use callback to send 123 data back in to Field Maps?

thanks for any help

16 Replies
AndrewPadilla
Occasional Contributor

@DougBrowning , @AnthonyJones5 Is there any news on the ability to callback a Survey123 field into Field Maps?  I have been able to hard code as noted above but would like to be able to use the callback feature and write a survey123 field back into Field Maps. Ideal Workflow: Open Field Maps popup, button opens survey123, writes two attributes to survey123, when survey is submitted callback opens Field Maps centers on feature, and writes two survey123 attributes. It's just the last bit I can't seem to get to work.

Using the above example it would look something like this: 

var callbackattributes = 'featureAttributes={"PolygonDataEntered":"$feature.Survey123attribute"}'

Thanks!

0 Kudos
DougBrowning
MVP Esteemed Contributor

@AndrewPadilla I do not think it will ever be possible because the URL is constructed at the time it is created in Field Maps.  At that point in the process there is no 123 field yet and you are not even in 123.  Which makes sense.  It would have to create a new URL when it gets to the 123 part.  

Only thing I can think of is to have a different URL generated in 123 form that they can click on.  But what will happen then is 123 form will still be open in the background in edit mode.  You can test but I think so.

Hope that makes sense.

0 Kudos
AndrewPadilla
Occasional Contributor

@DougBrowning  Thanks for your quick reply. I figured that might be the case. That would turn a survey submission into a two step process, one to change the Field maps attribute and one to submit the survey. Alternatively, after callback to Field Maps I might add a switch field where the users could manually record whether a survey was completed. We are working offline and a submitted survey could be either a survey or updates to child tables only. 

0 Kudos
DougBrowning
MVP Esteemed Contributor

You could harcode two different URLs?  Like one link is update tables only and the other is survey updates?

You could also use arcade after the fact to display the status in the map. 

0 Kudos
AndrewPadilla
Occasional Contributor

 @DougBrowning I took you suggestion and hardcoded two different URL buttons, it should work out well.

FrancisCorbett
New Contributor II

What I'm trying to achieve:

A non-ESRI app has fields that record lat/long. Embedded within the app is a button with html that calls Field Maps with the option to add a point and lat/long fields are calculated there. Is there a way that a callback URL can be created which after data is created in Field Maps calls the URL of the non-ESRI app with the lat/long appended? So the callback is dynamic but only created after Field Maps is called? Does this makes sense? Anyone any ideas? I'm expecting the answer to be no. Workaround would be not using a callback, but having a calculated field with the URL in Field Maps which opens the non-ESRI app when tapped.

0 Kudos
AnthonyJonesRSK
Occasional Contributor II

Hi Francis,

As far as I'm aware I don't believe this is possible. As Doug suggests above you cannot pass data from the app that is opened by the url (in your case Field Maps, in ours S123) via the call back. You would need to do as you suggest and have a separate url generated in the pop up of Field Maps that passes the lat/long back to your other app. Not sure if this will cause issues though as it may open a separate instance of your other app i.e. you will have the original session that opens Field Maps still running but then the link from Field Maps may open a new session. This obviously depends how your other app works so may be something to look into. Could your process possibly start with Field Maps and the location recording?

Cheers

Anthony