Dashboard and Survey123 Functionalities

326
0
11-15-2021 07:19 AM
Anthony_Mosinski
New Contributor II

Is there a way for a dashboard to recognize how many survey123 surveys are currently opened? We have a reservation system built for Ohio hunters to use to check into certain properties. Each property has a limited number of spots. We currently have the dashboard set up so if the number of spots available gets to or is less than 0 the link for the survey will not work. However, we do not want the number to ever be less than 0 but we are getting numbers in the negatives. I believe this is because multiple people can have the survey open at the same time and submit it resulting in negative numbers. I am wondering if there is a way for the dashboard to count the number of surveys currently opened, or something that limits users to the spots available. I am also open to other ideas as to how we can solve this issue.

We have also implemented a timer so hunters cannot sit on spots, but still in under 3 minutes the spots are filling up more than they should. Additionally, survey123’s timer is editable in mobile surveys and sometimes defaults to --:-- -- making it so hunters cannot check in. I am not sure there is a fix to this as these are know issues with survey123 but if anyone has suggestions I would love to hear them.

Anthony_Mosinski_0-1636989036193.jpeg

Below are a few screen shots showing the multiple scenarios, all are okay except for the negative example. This is saying the property has 7 hunters checked into a property that should only allow 3. Also, I pasted in the arcade scripts we are currently using to get the current number of submissions along with the link for submissions. 

If you would like to see the dashboard you can view it here https://odnr.maps.arcgis.com/apps/dashboards/6e59777a43e3471ab3d26ffd9586fe2b

Anthony_Mosinski_1-1636989036197.jpeg

Anthony_Mosinski_2-1636989036199.jpeg

Anthony_Mosinski_3-1636989036201.jpeg

Anthony_Mosinski_4-1636989036202.jpeg

 

Here's Arcade script that determines spots left.

//Calculates number of hunting spots remaining on a property for a specific date

//First filters by currently selected property, then by date, and counts number of records

//Subtracts the result from property's original number of spots

//SQL function to specify range between current date and 8pm night before

function GetDate_8pm() {

    var t = DateAdd(Today(),20,'hours');

    If (Hour(Now()) < 20) {

        t = DateAdd(Today(),-1,'days');

        t = DateAdd(t,20,'hours');

    }

    return t

}

//Convert OLHAP Survey GUID to string to match Check-in PropertyID format

var currentguid = Text($feature.globalid)

//return currentguid

//Create variable to reference OLHAP Check-in table

var checkintbl = FeatureSetByName($map,"OLHAP Check In_TEST")

//Filter Check-in table by currently selected PropertyID

var Propfltr = Filter(checkintbl, 'PropertyID = @currentguid')

//Create date filter variable

var testdate = GetDate_8pm()

var testdate_tom = DateAdd(testdate,1,'day')

var testdatetxt = Text(GetDate_8pm())

var testdate_tomtxt = Text(testdate_tom)

//Filter by date the records previously filterd by property

var fltr = Filter(Propfltr, 'DateAttending_Survey >= @testdatetxt And DateAttending_Survey < @testdate_tomtxt')

//return fltr

//Count remaining records

var cntfltr = Count(fltr)

//Subtract count from property's original number of spots

var spotsleft = Text($feature.NumHuntersAllowed - cntfltr, "#,###")

return  spotsleft

 

The following creates the survey URL from multiple variables.

//Variables for url

var numhunt = Text($feature.NumHuntersAllowed)

var ApplicantEmail = $feature.ApplicantEmail

var LandName = Text($feature.LandName)

var ExternalNotes = Text($feature.External_Notes)

var timenow = Now()

var timezero = Date(0)

var ETick = DateDiff(timenow, timezero)

//{expression/expr1} for url's "center="

var polyx = text(centroid($feature).x);

var polyy = text(centroid($feature).y);

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 latlon = "";

var result = "";

var latlon = metersToLatLon(polyx, polyy);

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

var surveyurl = "https://survey123.arcgis.com/share/0c9ad94cc5dc43a9ad64593c9ec6ea49?open&field:PropertyID=" + currentguid + "&field:AvailableSpotsToday=" + numhunt + "&field:LandownerEmail=" + ApplicantEmail + "&field:PropertyName=" + LandName + "&field:PropertyNotes=" + ExternalNotes + "&center=" + result + "&encodeUrlParams=true" + "&tick=" + ETick

// compare to original url: "https://survey123.arcgis.com/share/7ba766ed0db94acca6bb43fdb996aeac?open&field:PropertyID={GlobalID}..."

//url is available in the pop up if there are spots left

if (spotsleft>0) {

    return surveyurl

}

else {

    return "";

}

0 Replies