Hi All! I am looking to calculate tenure (based on embedded data coming from SFDC) for a customer that responds to a survey. The format of the date is Year-Month-Day. I don’t have a ton of experience with custom coding. Any help or guidance would be greatly appreciated!
Solved
How do I use embedded data to calculate tenure based on the response date?
Best answer by TomG
No ‘var’ is a JavaScript command that declares variable names. Don’t change it. I did have the year token wrong. It should be:
Qualtrics.SurveyEngine.addOnload(function() {
var DateTime = luxon.DateTime;
var startDate = DateTime.fromFormat("${e://Field/SFDC}","yyyy-MM-dd");
var tenure = DateTime.now().diff(startDate, ['years','months']).toObject();
Qualtrics.SurveyEngine.setEmbeddedData('tenure',tenure.years);
});
Leave a Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.