Trying to set embedded data from an answer | XM Community
Question

Trying to set embedded data from an answer

  • 23 December 2019
  • 3 replies
  • 33 views

Userlevel 1
Badge
Hello,

I have a question with 30 different answers. I would like to set or add embedded data based on each response but still use the same identifier.
Currently I have this so far. Theres a syntax error and Im really green with Java but I want to learn.
What I am looking to do is for each answer set the embedded data (SBAName) so I can use the email address to be piped into an action later on. This saves me creating so many actions and branches in the flow.

'''Qualtrics.SurveyEngine.addOnload(function(
{
this.questionclick = if (element.type == 'radio')
{ var SBAName = "${e://Field/SBAName}";
Qualtrics.SurveyEngine.addEmbeddedData("DavisSBA","agfor@mail.wvu.edu");
}
});
'''
Thank you in advance for your help

3 replies

Userlevel 7
Badge +27
this.questionClick has to be a function, as in:
```
this.questionClick = function(event, element) {
...
}
```
Userlevel 1
Badge
I want to use set.embeddeddata or add.embeddeddata but it is based on an answer. What am I missing here?
Userlevel 1
Badge
Would this be better?

Qualtrics.SurveyEngine.addOnload(function()
{
this.questionclick = function(event,element)
{
consol.log(event,element);
if (element.type == 'radio')
{
var choiceNum = element.id.split('~')[2];
if (choiceNum == 1)
Qualtrics.SurveyEngine.addEmbeddedData("SBAEmail","email.address@email.com");
}

}
});

Leave a Reply