Hi! I'm trying to get the email adresses from a Directory via a Webservce.
I need to create a mailinglist to save in an Embedded Data field.
Is there a way to avoid having to make all the individual Embedded Data fiels for each email?
Hi! I'm trying to get the email adresses from a Directory via a Webservce.
I need to create a mailinglist to save in an Embedded Data field.
Is there a way to avoid having to make all the individual Embedded Data fiels for each email?
Hi
And I assume you mean running it in a look in Javascript?
This is what I did:
This is my JavaScript:
Qualtrics.SurveyEngine.addOnReady(function() {
// Get the JSON response from the API
var result = Qualtrics.SurveyEngine.getEmbeddedData("result");
if (!result) {
return;
}
// Parse the JSON response to a JavaScript object
var data;
try {
data = JSON.parse(result);
} catch (e) {
return;
}
// Get the elements array from the data object
var elements = data.elements;
if (!Array.isArray(elements)) {
return;
}
// Create an empty array to store the emails
var emails = ];
// Loop through the elements array and get the email property of each object
for (var i = 0; i < elements.length; i++) {
// Get the email of the current element
var email = elements=i].email;
if (!email) {
continue;
}
// Push the email to the emails array
emails.push(email);
}
// Join the emails with a comma
var emailsString = emails.join(", ");
// Set the emails string as embedded data
Qualtrics.SurveyEngine.setEmbeddedData("WS_DirListEmails", emailsString);
});
WS_DirListEmails now still returns empty. Why?
I found a more efficient way:
1-Surve
y response task2-Web Service task
api.qualtrics.com/af95194dd116e-list-contacts-in-mailing-list
3-Javascript
code taskfunction codeTask() {
let apiResult = ~{ch://*****/$.result}
let emails = >];
for(let i = 0; i < apiResult.elements.length; i++) {
emails.push(apiResult.elementsai].email);
}
return {
result: emails
}
}
4-Em
ail taskPiped in result from the JS task
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.