Highlight Survey response if present date exceeds time limit

604
3
Jump to solution
10-20-2021 02:05 PM
JohnnyHarley232
New Contributor III

I have a survey that inspectors collect test samples from the field. There is a field in Survey123 that has a "time Limit" field that is defined by the max number of days the test needs to sent to a lab. The inspector will go into the Inbox of Survey123 and edit the Upload date field, days later and resubmit. If the inspector does not upload the test within a certain amount of time.. I want either an email to be sent via webhooks or for a cell to highlight a certain color in the submitted survey response in the inbox. Is this even possible? I am trying to tell my client if it is or not. 

 

Thanks!

Tags (1)
0 Kudos
2 Solutions

Accepted Solutions
Philip-Wilson
Esri Notable Contributor

Hi @JohnnyHarley232,

Yes this should be possible, and could be done in a few different ways.

Webhooks are only sent when the survey is submitted, not when it is open or in use. So if you created a webhook to send when they submit they survey, it could use the dates to send an email or notification that the date limit had passed, but the survey would have already been sent to feature layer, so not sure if that is useful?

For an indication while the survey is open, you could use relevant note question types in the survey, on different pages or after different questions, to do a date/time calculation based on the start/submitted time and whether the limit has been reached. If the note is valid, you could display it in different colours (yellow, orange, red) to indicate the date/time state or how close you are to time limit. These notes would just use relevant statements to be displayed or not displayed so the user knows and sees it as they scroll through the form.

Otherwise you could use constraints on certain questions, to do the same date/time limit check, but in this case the constraints are more forceful, meaning the survey can not be submitted if the constraint if not valid. It could be the last question on the survey, asking "Are you ready to submit?" and based on that answer of yes, check the date/time and stop them submitting if the limit is reached. It would provide a warning/error message about the date/time limit not being valid for that question.

Another option to try is formatting the instance_name, which is the label you see for each survey record in the Inbox list, and use html formatting to use different colours for the label based on the date and time left until date limit is reached. The surveys could be yellow, orange and red text, the closer the date limit gets closer, but you need to base this off a field/calculation in the survey. This would mean the user sees this before they even open the survey record, and it gets updated when you refresh the Inbox. Not sure this will work exactly, would need some testing and trial and error.

Hope this helps.

Regards,

Phil.

View solution in original post

0 Kudos
DeonLengton
Esri Contributor

I attempted Philip's last provided option:

Outcome:

DeonLengton_1-1634801372091.png

 

I calculated the "age" of a feature with:

int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))>0

Then used an if() statement in the Instance Name setting to alter the coloring of the text:

if(int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))>0,
concat("<font color='red'>OVERDUE by ",int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))," day(s)</font"),
concat("<font color='blue'>Due in ",-1*int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))," day(s)</font"))

Ive attached the XLXS file for your convenience

View solution in original post

3 Replies
Philip-Wilson
Esri Notable Contributor

Hi @JohnnyHarley232,

Yes this should be possible, and could be done in a few different ways.

Webhooks are only sent when the survey is submitted, not when it is open or in use. So if you created a webhook to send when they submit they survey, it could use the dates to send an email or notification that the date limit had passed, but the survey would have already been sent to feature layer, so not sure if that is useful?

For an indication while the survey is open, you could use relevant note question types in the survey, on different pages or after different questions, to do a date/time calculation based on the start/submitted time and whether the limit has been reached. If the note is valid, you could display it in different colours (yellow, orange, red) to indicate the date/time state or how close you are to time limit. These notes would just use relevant statements to be displayed or not displayed so the user knows and sees it as they scroll through the form.

Otherwise you could use constraints on certain questions, to do the same date/time limit check, but in this case the constraints are more forceful, meaning the survey can not be submitted if the constraint if not valid. It could be the last question on the survey, asking "Are you ready to submit?" and based on that answer of yes, check the date/time and stop them submitting if the limit is reached. It would provide a warning/error message about the date/time limit not being valid for that question.

Another option to try is formatting the instance_name, which is the label you see for each survey record in the Inbox list, and use html formatting to use different colours for the label based on the date and time left until date limit is reached. The surveys could be yellow, orange and red text, the closer the date limit gets closer, but you need to base this off a field/calculation in the survey. This would mean the user sees this before they even open the survey record, and it gets updated when you refresh the Inbox. Not sure this will work exactly, would need some testing and trial and error.

Hope this helps.

Regards,

Phil.

0 Kudos
DeonLengton
Esri Contributor

I attempted Philip's last provided option:

Outcome:

DeonLengton_1-1634801372091.png

 

I calculated the "age" of a feature with:

int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))>0

Then used an if() statement in the Instance Name setting to alter the coloring of the text:

if(int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))>0,
concat("<font color='red'>OVERDUE by ",int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))," day(s)</font"),
concat("<font color='blue'>Due in ",-1*int(decimal-date-time(today()) - decimal-date-time(${ExpDate}))," day(s)</font"))

Ive attached the XLXS file for your convenience

Philip-Wilson
Esri Notable Contributor

Wow @DeonLengton, thats awesome. Nice work!

0 Kudos