How to display text if today's date is not 2/5/2024

441
4
01-03-2024 04:11 PM
LS1
by
New Contributor III

What would the xlsform line look like to display the message "invalid survey" and exit the survey if the user tries to collect data on any date other than 2/5/2024. I know this should be simple but I can't get it to work. In other words, I want the relevant column to evaluate today's date and if it's a date other than 2/5/24, the "invalid survey" will be displayed.

This is the note (message) I want to display when the user presses collect to open the survey and the date is anything aside from 2/5/2024. I thought that I just need a constraint in the "relevant" column for the survey to know whether to be displayed or not.  Just looking for what to put into the relevant column and/or additional lines prior to this line if additional logic is needed.

type                     name                                                label

 

notesurveyerror<font color="red"><b>This survey can only be used to open drop boxes on Monday, February 5</b>
</font>

 

 

4 Replies
Raul
by
New Contributor III

Maybe you're looking to do something like this. If you want to play around with the functionality you can either change the default value of date_of_interest_str field, and/or remove the read only constraint on curr_date field

0 Kudos
LS1
by
New Contributor III

Thanks, This is the message I want to display if the user tries to use the survey on any date other than 2/5/2024. I thought that I just need a constraint in the "relevant" column for the survey to know whether to be displayed or not.  Just looking for what to put into the relevant column and/or additional lines prior to this line if additional logic is needed.  I can figure out how to show or hide the rest of the questions based on relevant column.

type                     name                                                label

 

notesurveyerror<font color="red"><b>This survey can only be used to open drop boxes on Monday, February 5</b>
</font>

 

0 Kudos
abureaux
MVP Regular Contributor

The calculation I have in my original post would do that. Just make your relevant column this: ${date_restriction}=1

0 Kudos
abureaux
MVP Regular Contributor

You can't just end a survey, but you can make all of the content relative. If a condition isn't met, the content wont show. It's up to the user to close/end the survey.

This restricts surveys to before Jan 5th:

abureaux_0-1704383909998.png

You can convert the time to a custom date format if you'd like by using format-date(). Here is the blog.

You will notice that the time is in a super unfriendly UNIX format. That is S123's default. If you want to know what a specific date is in UNIX, you can get that quickly with this (below). Just select a date, and it will show you the UNIX date.

abureaux_1-1704384010044.png

 

0 Kudos