AnsweredAssumed Answered

Attribute Expression Blank

Question asked by wogcarver on Sep 25, 2018
Latest reply on Sep 26, 2018 by SPrindle-esristaff

I am currently making Collector/Survey123 data collection and map for inventorying campsites. I am opening Survey 123 from collector by adding a link in the pop-up following arcgis's url scheme. Many of the fields have to be calculated and so I made a single attribute expression that creates the majority of the link which I named Resurvey Link {expression/expr0}. Then in the url I put


but when I click the link it simply appears as


If I open the attribute table, under Resurvey Link the two campsites I currently have in the dataset are empty.

When I test the code within the expression I get the exact result I expected, not a blank string....

Attached below is the entire expression and then the output when I test it.

function getCampsiteId() {
   return Number(Split($feature["Campsite_ID"], "-")[5]);


function getCampsiteOrigYear() {
   var iYearShort = Number(Split($feature["Campsite_ID"], "-")[4]);
   var sYear = '';
   if (iYearShort <= 99 && iYearShort >= 94) {
      sYear = '19' + iYearShort;
   else {
      sYear = '20' + iYearShort;
   return Date(Number(sYear), 0, 1);


function getDistrict() {
   return Decode($feature.Wilderness,
      'Blood Mountain Wilderness Area', 'BRRD',
      'Brasstown Wilderness Area', 'BRRD',
      'Cohutta Wilderness Area', 'CRD',
      'Mark Trail Wilderness Area', 'CRRD',
      'Raven Cliffs Wilderness Area', 'CRRD',
      'Rich Mountain Wilderness Area', 'BRRD',
      'Tray Mountain Wilderness Area', 'CRRD',


function getGeometry() {
   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;


function getResurveyLink() {
   var link = '?itemID=2aab379ca46543e9a812ef07a387c802';
   var geom = getGeometry();
   var fields = [
      {name: 'District', val: getDistrict()},
      {name: 'Wilderness_CRD', val: getWilderness('CRD')},
      {name: 'Wilderness_BRRD', val: getWilderness('BRRD')},
      {name: 'Wilderness_CRRD', val: getWilderness('CRRD')},
      {name: 'New_Site', val: 'no'},
      {name: 'Date_Orig_Collection', val: getCampsiteOrigYear()},
      {name: 'Campsite_ID_Number', val: getCampsiteId()},
      {name: 'Dist_Along_Trail', val: $feature["Dist_Along_Trail"]},
      {name: 'Date_Collected', val: Now()},
      {name: 'Ground_Dist', val: $feature["Ground_Dist"]},
      {name: 'Tree_Damage', val: $feature["Tree_Damage"]},
      {name: 'Disturbed_Area', val: $feature["Disturbed_Area"]},
      {name: 'Overall_Imp', val: $feature["Overall_Imp"]},
      {name: 'Between_Trail_Stream', val: $feature["Between_Trail_Stream"]},
      {name: 'Water_Source', val: $feature["Water_Source"]},
      {name: 'Water_Dist_FT', val: $feature["Water_Dist"]},
      {name: 'Social_Trails', val: $feature["Social_Trails"]},
      {name: 'Main_Trail_Designated', val: $feature["Main_Trail_Designated"]},
      {name: 'Trail_Dist_FT', val: $feature["Trail_Dist"]},
      {name: 'Impact_Area', val: $feature["Impact_Area"]},
      {name: 'Litter_Trash', val: $feature["Litter_Trash"]},
      {name: 'Pot_Site_Expan', val: $feature["Pot_Site_Expan"]},
      {name: 'NNIS_Presence', val: $feature["NNIS_Presence"]},
      {name: 'Site_Condi', val: $feature["Site_Condi"]},
      {name: 'Rec_Site_S', val: $feature["Rec_Site_S"]},
      {name: 'Admin_Structures', val: $feature["Admin_Structures"]}

   for (var i=0, j=Count(fields); i<j; i++) {
      link += '&field:' + fields[i].name + '=' + fields[i].val;

   link += '&center=' + geom;

   return link;


function getWilderness(sWild) {
   if (sWild == 'CRD') {
      return Decode($feature.Wilderness,
         'Cohutta Wilderness Area', 'CO',
   else if (sWild == 'BRRD') {
      return Decode($feature.Wilderness,
         'Brasstown Wilderness Area', 'BR',
         'Blood Mountain Wilderness Area', 'BM',
         'Rich Mountain Wilderness Area', 'RM',
   else if (sWild == 'CRRD') {
      return Decode($feature.Wilderness,
         'Mark Trail Wilderness Area', 'MT',
         'Raven Cliffs Wilderness Area', 'RC',
         'Tray Mountain Wilderness Area', 'RM',


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];


return getResurveyLink();

Test Result



Not sure what I'm doing wrong. I originally had null instead of blank strings in the Decode functions default value parameter, but switched them to test if that was the issue. Any help would be appreciated to get me on the right track. It seems like my logic is functional, but I've messed something up somewhere...