Hi
I need to import a point ID and the x,y location of the point from a Field Map into Survey123 using the pop up in Field Maps. I have the arcade function working (using advice from other posts here on the forum) and when I run the arcade script it gives me the output that I need as text.
So my question is - how do I now run the arcade function "location" in the pop up so that when the point is clicked on the arcade function is run and the html address generated is used to open and populate the Survey123 form?
I have tried many variations of including the expression in a text box but without success....
Many thanks for your help
Solved! Go to Solution.
You can use {expression/expr0} or whatever number the attribute expression is in the pop up to add it to the text box of pop up. The way I have it set up is using the expression to create the whole URL and then placing it in as a hyperlink in the pop up (I was using the HTML editor for it, this was also a couple years back I set this up originally)
function MetersToLatLon(x, y) {
// Converts XY point from Spherical Mercator EPSG:3857(Web Mercator Auxiliary Sphere) to lat/lon in WGS84 Datum (EPSG:4326).
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}
function CreateURLSurvey(lat, lon) {
var url_scheme = "https://survey123.arcgis.app/?itemID=4######################76a48&callback=https://fieldmaps.arcgis.app";
var url = url_scheme + "&field:asset_id="+$feature.UNITID+"&field:subarea="+$feature.SUBAREA;// Repeat this line as many times as required based on how many fields you want populated. For this example AssetID will be populated from otherfeatid
var url = url + "¢er=" + lat + "," + lon;// This is the line that defines the location
Console(url);
return url;
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;
Then in the pop up in a text item while looking at the HTML it looks like:
<p>
<a href="{expression/expr0}" target="_blank"><span style="font-size:large;">Garbage Collection Form</span></a>{expression/expr0}
</p>
I will note that I sporadically had issues with this code, I think it's probably to do with the specific projection we use (I'm in New Brunswick, Canada and occassionally it would toss the point in Lithuania and I could never figure out why and we scrapped this method because of it, but I've seen lots of people using it without issue so I think that was just a coordinate system issue).
Do you mean before they submit the point? I think they have to submit then click on the link.
In Field Maps when you click on a point it brings up the pop up. You can configure a link in the pop up to open Survey123 and automatically populate the survey123 app with data from that point. I have successfully configured this process for just field data using a text box in the pop up configuration. I would like to know how to set up a similar process using the arcade function in the pop up configuration to also automatically bring the location of the point into Survey123 - many thanks
You can use {expression/expr0} or whatever number the attribute expression is in the pop up to add it to the text box of pop up. The way I have it set up is using the expression to create the whole URL and then placing it in as a hyperlink in the pop up (I was using the HTML editor for it, this was also a couple years back I set this up originally)
function MetersToLatLon(x, y) {
// Converts XY point from Spherical Mercator EPSG:3857(Web Mercator Auxiliary Sphere) to lat/lon in WGS84 Datum (EPSG:4326).
// Source: http://www.maptiler.org/google-maps-coordinates-tile-bounds-projection/
var originShift = 2.0 * PI * 6378137.0 / 2.0;
var lon = (x / originShift) * 180.0;
var lat = (y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return [lat, lon];
}
function CreateURLSurvey(lat, lon) {
var url_scheme = "https://survey123.arcgis.app/?itemID=4######################76a48&callback=https://fieldmaps.arcgis.app";
var url = url_scheme + "&field:asset_id="+$feature.UNITID+"&field:subarea="+$feature.SUBAREA;// Repeat this line as many times as required based on how many fields you want populated. For this example AssetID will be populated from otherfeatid
var url = url + "¢er=" + lat + "," + lon;// This is the line that defines the location
Console(url);
return url;
}
var latlon = MetersToLatLon(Geometry($feature).X, Geometry($feature).Y);
var url = CreateURLSurvey(latlon[0], latlon[1]);
return url;
Then in the pop up in a text item while looking at the HTML it looks like:
<p>
<a href="{expression/expr0}" target="_blank"><span style="font-size:large;">Garbage Collection Form</span></a>{expression/expr0}
</p>
I will note that I sporadically had issues with this code, I think it's probably to do with the specific projection we use (I'm in New Brunswick, Canada and occassionally it would toss the point in Lithuania and I could never figure out why and we scrapped this method because of it, but I've seen lots of people using it without issue so I think that was just a coordinate system issue).
Many thanks - that is now working
My confusion was between the "arcade" section and the "attribute expressions" section of the pop-ups configuration. Once I abandoned the arcade workflow and added the script as an attribute expression it all works perfectly. That has been bugging me for ages! so many thanks