Select to view content in your preferred language

Callback to whatever map feature layer is currently being used in

843
2
Jump to solution
03-14-2023 11:11 AM
SeanHarkins2
New Contributor

I'm trying to accomplish something that I assume is impossible at this point. But here goes, let's see what ideas come.

I'm trying to sort out a way to callback to whatever offline map a given layer is on.

Background: I have a survey layer people will work off of, I have put together a callback link (adapted from someones previous question) using Arcade which pushes users into Survey123, then after submission of the survey, it calls back into Field Maps and edits the selected point, so all the user needs to do is tap on "Submit." That code works online and offline as long as a specific map is in use. All good. 

What I'm trying to do is "wildcard," or auto-populate the itemID in the callback script/URL so the user does not need to have that specific map; instead whatever map the user has with the survey layer included will get called back.

I hope the brains in here can help. Thank you in advance, even if the answer is "you can't do that"

Current callback link code I adapted from a different question:

// Create date variables for conditional evaluation
var sdate = Today()
var dat = Sum(Month(sdate), 1) + '-' + Day(sdate)

// To launch survey123 from map
var urlsource ="arcgis-survey123://?itemID=1061a14a98c54dab8237603758b6e429&"
 
//Format globalid to "link" survey point to map data
var fglobalid = Mid($feature.globalid, 1,36)

//Generate other url parameters to pass to survey123
var params = {
  "field:eS": $feature.eS,
  "field:lS": $feature.lS,
  "field:proj_unit": $feature.Unit,
  "field:GUID": $feature.GlobalID,
  "field:project": $feature.Project,
  "field:GPSID": $feature.GPSID,
  "field:FeatureType": "Point",  
};


// Create callback portion of link using itemID (map ID) and featureSourceURL (services link to the layer //containing the feature to be edited following survey submission)
// EDIT THIS LINK FOR  MAP AND POINT FEATURE CLASS
var callback = {
}

// // Add featureID (must be var fglobalid) portion of callback link
var callbackid = "featureID=" + fglobalid

// Add featureAttributes portion of link. This is the conditional portion of the link, which will vary based on //month and day. Outside the survey season, this link will not update anything.
var callbackattribute = iif(dat >= '6-01' && dat <= '6-30', 'featureAttributes={"early_surv":"E"}', iif(dat >= '7-01' && dat <= '8-15', 'featureAttributes={"late_surv":"L"}', ''))

// Return the entire link/URL. This is what the FieldMaps app is following when you click the link to enter //survey data
return urlsource + UrlEncode(params) + "&" + UrlEncode(callback) + "%26" + UrlEncode(callbackid) + "%26" + UrlEncode(callbackattribute)
0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

What I do is just use &callback=https://fieldmaps.arcgis.app then it will just flip back to field maps with whatever they had open when they clicked the link to 123.  

View solution in original post

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

What I do is just use &callback=https://fieldmaps.arcgis.app then it will just flip back to field maps with whatever they had open when they clicked the link to 123.  

0 Kudos
SeanHarkins2
New Contributor

Really! Well that's a simple fix. I'll give it a shot! Thank you Doug!