Collector (Aurora) Custom Expressions in Custom URL Scheme Error

7634
11
04-11-2019 07:44 AM
by Anonymous User
Not applicable

I am writing a campsite collection form that uses Collector and Survey 123. I set this up using Arcmap's custom URL scheme. The user can select a site in collector and two links are included in the pop-up. One says Resurvey Campsite the other says Survey New Site. The resurvey link has a rather lengthy URL that attempts to pre-fill many of the fields of survey123. This worked other than the attributes that I had custom expressions to set correctly. The final bit the resurvey link sends the coordinates of the campsite using another custom expression.

Unfortunately, the custom expressions would work on my desktop, but when I opened collector on the iPad issued to me, they would not. I posted on this issue and was informed that Collector Aurora would support custom expressions in the URL link. I signed up for the beta and had fair success with the iPad. Some custom expressions still didn't send but coordinates did, and they were the most important one to work.

Now that Collector (Aurora) is officially out, I went out and field tested the two apps to discover that custom expressions are once again not working on my iPad or Samsung Galaxy phone. I am curious is this is a known issue and can be fixed or not, as it is rather pivotal that I can at least send the coordinates of the point to Survey 123. Below is my custom URL scheme for the resurvey link and the steps I went through to test if the custom URL was truly the issue

Resurvey Campsite Link - (&center={expression/expr2} is the non-functioning part)

arcgis-survey123://?itemID=1284e4815d4c4995b5809f1a51a83f9f&field:District={expression/expr1}&field:Wilderness_CRD={expression/expr3}&field:Wilderness_BRRD={expression/expr4}&field:Wilderness_CRRD={expression/expr5}&field:New_Site=no&field:Date_Orig_Collection={calOrigYear}&field:Campsite_ID_Number={expression/expr0}&field:Dist_Along_Trail={Dist_Along_Trail}&field:Ground_Dist={Ground_Dist}&field:Tree_Damage={Tree_Damage}&field:Disturbed_Area={Disturbed_Area}&field:Overall_Imp={Overall_Imp}&field:Between_Trail_Stream={Between_Trail_Stream}&field:Water_Source={expression/expr7}&field:Water_Dist_FT={Water_Dist}&field:Social_Trails={Social_Trails}&field:Main_Trail_Designated={Main_Trail_Designated}&field:Trail_Dist_FT={Trail_Dist}&field:Impact_Area={expression/expr6}&field:Litter_Trash={Litter_Trash}&field:Pot_Site_Expan={Pot_Site_Expan}&field:NNIS_Presence={NNIS_Presence}&field:Site_Condi={Site_Condi}&field:Rec_Site_S={expression/expr8}&field:Admin_Structures={Admin_Structures}&center={expression/expr2}

Resurvey Campsite Link Output on Desktop

arcgis-survey123://?itemID=1284e4815d4c4995b5809f1a51a83f9f&field:District=CRRD&field:Wilderness_CRD=&field:Wilderness_BRRD=&field:Wilderness_CRRD=MT&field:New_Site=no&field:Date_Orig_Collection=2007&field:Campsite_ID_Number=1&field:Dist_Along_Trail=&field:Ground_Dist=1&field:Tree_Damage=1&field:Disturbed_Area=1&field:Overall_Imp=3&field:Between_Trail_Stream=&field:Water_Source=1&field:Water_Dist_FT=45&field:Social_Trails=%20&field:Main_Trail_Designated=&field:Trail_Dist_FT=-100&field:Impact_Area=3&field:Litter_Trash=%20&field:Pot_Site_Expan=Medium&field:NNIS_Presence=Unknown&field:Site_Condi=Fair&field:Rec_Site_S=&field:Admin_Structures=N%2FA&center=34.745047%2C%20-83.844254

Expression/expr2 - Code to calculate geometry

function metersToLatLon(mx, my) {

   var originShift = 2.0 * PI * 6378137.0 / 2.0;

   var lon = (mx / originShift) * 180.0;

   var lat = (my / originShift) * 180.0;

   lat = 180.0 / PI * (2.0 * Atan(Exp(lat * PI / 180.0)) - PI / 2.0);

return [lat, lon];

}

var poly = Geometry($feature);

var result = '';

if (!IsEmpty(poly)) {

   var latlon = metersToLatLon(poly.x, poly.y);

   result = Round(latlon[0], 6) + ', ' + Round(latlon[1], 6);

}

return result;

Process for Testing Error

  • After noticing the error in the field, I retested each device in the office

     Desktop (Success)                          iPad (Error) - Newest Collector App             Android (Error) - Beta App

  • I then created a third link that only included the code to send the coordinates and tested it on each device

    Link - arcgis-survey123://?itemID=1284e4815d4c4995b5809f1a51a83f9f&center={expression/expr2}

    Desktop (Success)                       iPad (Error) - Newest Collector App             Android (Error) - Beta App

  • Finally, I created one more link that sent a fixed coordinates instead of using the custom expression

Link - arcgis-survey123://?itemID=1284e4815d4c4995b5809f1a51a83f9f&center=34.734837%2C%20-83.916739

     Desktop (Success)                       iPad (Success) - Newest Collector App             Android (Success) - Beta App

Thank you for anyone who has made it this far, I would really appreciate any help on resolving this bug as I'm super excited about using Collector and Survey 123. Good work!

11 Replies
MarkBockenhauer
Esri Regular Contributor

Thanks for your write up.  In a different context (ArcGIS Pro) I have noticed that in some instances the geometry function will return values in the coordinate system of the source data, while in others it returns values in the coordinate system of the map.  I mention this because your result difference  -9331888.963170711 vs. -83.829785  Is what I have seen while using a similar expression in ArcGIS Pro - Labeling vs. Popup vs. Calculation - same expression yields different results.  It would appear that there is something in the webmap use case that triggers similar inconsistencies.

0 Kudos
JoshConrad1
New Contributor III

@MarkBockenhauer @DougBrowning @JamesTedrick @IsmaelChivite 

All:

I have been experiencing the same issues described in this thread: trying to create an attribute expression that calculates lat/long coordinates from a hosted feature layer, then integrate Field Maps with Survey123 to open a form and have the geopoint plot the submitted survey on top of the feature using the result of the attribute expression using a custom URL via the custom URL popup (&center=).

I have been using the "Expression/expr2 - Code to calculate geometry" formula called out in this post (and a multitude of others on the community page) and it was correctly calculating the coordinates in ArcGIS Online Web Viewer Classic, but then when we tested this functionality in the field, the point was not mapping.

I found that the original formula in the "Expression/expr2 - Code to calculate geometry" results in an Array data type, with associated brackets. These brackets do not show up in ArcGIS Online, but when you view the popup in Field Maps, you can see the brackets. So because of this, i tested further and in the original function, i removed the brackets in the result line, which worked but was not perfect. It was not perfect because the coordinate results ended up being truncated to 2 decimals, and even though the submitted form was executing, the point was being plotted hundred of feet away.

After 10 hours of testing and researching these threads (which by the way, all of the contributions are EXPONENTIALLY HELPFUL AND I AM SO GRATEFUL OF YOUR KNOWLEDGE) i was able to find the CORRECT SOLUTION:

1.) Create an attribute expression for latitude:

var lat;
var originShift = 2.0 * PI * 6378137.0 / 2.0;

lat = number(Geometry($feature).y / originShift) * 180.0;
lat = 180.0 / PI * (2.0 * Atan( Exp( lat * PI / 180.0)) - PI / 2.0);
return lat;

2.) Create an attribute expression for longitude:

var lon;
var originShift = 2.0 * PI * 6378137.0 / 2.0;

lon = number(Geometry($feature).x / originShift) * 180.0;
return lon;

3.) Because of the "number" identifier, In ArcGIS Online Web Map Viewer Classic go to Configure Popups, make sure your pop up display is custom, then the important step is to click Configure Attributes. Navigate to the newly created expressions and expand the decimal places to a minimum of 5.

4.) Lastly, in the custom URL make the "&center={expression/expr3},{expression/expr4} where expr 3 is Lat and expr 4 is Long.

I have been testing since i discovered this and it has been running smoothly. Happy Mapping!

 

 

 

 

 

 

 

0 Kudos