AnsweredAssumed Answered

Access Feature Class in Attribute Expression

Question asked by wogcarver on Sep 25, 2018
Latest reply on Sep 26, 2018 by xander_bakker

I am working with a campsite surveying map that is connected to Collector and Survey 123. The campsite id is fairly complicated string of numbers that looks like [08-03-06-350-18-001] with the last to number sets [18-001] being the year the campsite was found and the ID number of sites found that year. 

 

In the above example the site was originally found in 2018 and it was the first site found. I am using a link within the popup following the custom url scheme to open Survey 123 and would like to be able pass the next needed ID. This can be done by selecting the last created point and having an expression that looks something like:

 

return Number(Split($feature["Campsite_ID"], "-")[5]) + 1;

(The field in the survey handling the last part of the ID is a Number).

 

This should function (I haven't actually tested this, made it up while typing this), but would require the user to find the last campsite which might be very far away.

 

Instead, I would like to write a function that loops through the current campsites and finds the last used campsite ID:

 

function FindMaxCampsiteId() {

   var aPointIds = [];

   for (var i = 0, j = $featureClass.points.length; i<j; i++) {

      aPointIds.push(Number(Split($featureClass.points[i].Campsite_ID)));

   }

   return Max(aPointIds);

}

 

return FindMaxCampsiteId() + 1;

 

All the documentation shows how to access the current feature ($feature) but I can't find anyway to access the entire dataset or other layers. (It be super helpful to be able to access a polygon layer that is also loaded into my Online Map).

Is it possible to do this and I'm missing this or is it not currently doable? Thanks ahead of time for any help!

Outcomes