Is there a way to autocalculate a survey expiration date? | XM Community
Skip to main content
The survey I am conducting needs to be completed within 7 days of another task. I upload the TaskDate as an embedded item in the contact list.

Is there a way to auto-calculate an expiration date for the individual emails that are sent out?

Alternatively, I can auto-calculate the expiration date in the excel contact sheet, is there a way to import an expiration date into a survey link?



Thanks!
I don't think you can do this in a built-in way, but you could use logic in your survey flow to handle it. I've seen some surveys where it checks after each block whether a condition is met and ends the survey if so.



You would probably need to evaluate the date using JavaScript as I don't think Embedded Data has that capability. So on the first page of the survey, you could have JavaScript doing something like:



```javascript

var expDate = Qualtrics.SurveyEngine.getEmbeddedData('customExpirationDate');

expDate = new Date(expDate);

if (expDate < new Date()) {

Qualtrics.SurveyEngine.setEmbeddedData('expired','true');

}

```



Then after that block you could add an if statement in the Survey Flow that says "If Embedded Data `expired` = `true` then End Survey.



Consider the fact that if people enter the survey in time but then leave and return after the time, this would not catch them. You would need this logic on every page of your survey in that case.
Thanks!



Right now I am manually entering the expiration dates when I send out the email link, but I can see this being easy to make a mistake or tedious after 100+ times. I'll see if I can get this to work
> @AVB said:

> Thanks!

>

> Right now I am manually entering the expiration dates when I send out the email link, but I can see this being easy to make a mistake or tedious after 100+ times. I'll see if I can get this to work



This sounds like you are distributing to each email address manually. If so, I have two suggestions:

1. Create a sample based on TaskDate, then distribute to that sample. That way, you are only doing one distribution a day where you have to set the link expiration.

2. Look into creating a script to use API to automate the distributions. The script could calculate the link expiration date and set it when it creates the distribution.
These are good suggestions, but unfortunately a limitation is the nature of recruitment. I am recruiting from a clinic, and each person has one week after their task to complete my survey. Not everyone will necessarily agree to my survey, and I cannot ethically receive the contact information or task date prior to their consent. I anticipate receiving a few participants a week over an extended period of time, so there will not be much overlap with TaskDate.



Right now, I plan to upload contacts individually with TaskDate and EndDate (7 days after task). I have EndDate embedded in the email text I send out to participants so they are aware when it expires.



As for the survey expiration, I am currently doing this manually but there is definitely room for improvement.



I may try the method above, or look into API to automate distribution. I am unfamiliar with API, so there may be a steep learning curve there.
Perhaps you can use a survey as a signup, then use the Web Service element in the survey flow to trigger an api distribution. That way you don’t have to build a backend, and you are getting contact info before an actual survey is triggered.
Thanks, that's a good idea for the contact info entry and distribution! I'll have to run it by the clinic (there may be some confidentiality concerns)



As for the survey expiration, right now I have the following embedded data

SurveyDate Date = ${date://CurrentDate/DS}

ChYMHDate Date Value will be set from Panel or URL.

EndDate Date Value will be set from Panel or URL.



In my flow after the first page, I have

Then Branch If:

If EndDate Is Less Than CurrentDate

End of survey



This is automatically taking me to the end of the survey regardless of the EndDate, is there a way to make this statement recognized or will I need to go the above javascript route?
Unfortunately the evaluators in Qualtrics all only evaluate numbers or exact text matches. To do dates you’ll need JavaScript
I don't seem to be able to get this to work.



in the JS per block I have:

var expDate = Qualtrics.SurveyEngine.getEmbeddedData('EndDate');

expDate = new Date(expDate);

if (expDate < new Date()) {

Qualtrics.SurveyEngine.setEmbeddedData('Expired','true');



in the Survey Flow logic after each block I have:

Then Branch If:

If Expired Is Equal to true

End Survey

Leave a Reply