hello Survey123 people.
I created a survey using Survey 123 Connect 3.12.232 to track Volunteer registration. I have a few fields for Check In and Check Out. When the Volunteer first register those 2 fields are blank (NULL) and later on they can comeback and check in or out. I added a basic JavaScript function (see below) to assign the "status' of the volunteer (Register, Checked In, Checked Out). As you can see on my images, everything seems to be working fine in design mode and mobile (IOS using Arcgis Survey 123) BUT when using the same survey online, the status value is always "Checked Out". Is there a different way to handle DATE field ?
Any help would be much appreciated
Thanks!
Dominic
***************************************************************
function drStatus(datein, dateout) {
if (datein === null && dateout === null)
return 'Register';
else if (datein !== null && dateout === null)
return 'Checked In';
else if (datein !== null && dateout !== null)
return 'Checked Out';
}
Solved! Go to Solution.
ok, thank you guys for your help.. I modified the function as follow and everything is working as expected.
function drStatus(datein, dateout) {
if (!datein && !dateout)
return 'Register';
else if (datein != null && !dateout)
return 'Checked In';
else if (datein != null && dateout != null)
return 'Checked Out';
}
Just a guess but there may be an issue with null or empty string''. maybe try isEmpty() Logical Functions | ArcGIS for Developers
Maybe you're using the wrong operator? This doc indicates that you are using too many equal signs. Formulas—ArcGIS Survey123 | Documentation
In the past I have not had to define variables. I think you need to put the following in the calculation field in your xlsx table:
if({datein} == '' and {dateout} == '', "Register',
if({datein} != '' and {dateout} == '', 'Checked in',
if({datein} != '' and {dateout} 1= '', 'Checked out')))
You may want to consult this article for help on determining empty or null values, I'm not sure if my solution is 100% correct Formulas—ArcGIS Survey123 | Documentation
EDIT
Sorry, didn't see that you're using JavaScript. I have not done that in Survey123.
ok, thank you guys for your help.. I modified the function as follow and everything is working as expected.
function drStatus(datein, dateout) {
if (!datein && !dateout)
return 'Register';
else if (datein != null && !dateout)
return 'Checked In';
else if (datein != null && dateout != null)
return 'Checked Out';
}