Convert imported file into an array accessed in JavaScript code block | XM Community
Solved

Convert imported file into an array accessed in JavaScript code block

  • 5 June 2018
  • 1 reply
  • 4 views

Badge +3
Has anyone been able to take an imported file (e.g., a list of contacts for distribution), convert a single field (e.g., email address) into an array that can then be used as part of a JavaScript code block within a single question? Thanks in advance for any help.
icon

Best answer by mattyb513 27 July 2018, 17:22

View original

1 reply

Userlevel 6
Badge +6
Yeah, this is pretty simple.

In the contact list, concatenate the items in the field with something that isn't normally used, like a `~` or `;`:

`email1@test.com~email2@test.com~email3@test.com`

Then in the JS editor, get the field:

`var customEmails = Qualtrics.SurveyEngine.getEmbeddedData('custom_emails');`

Now split it into an array:

`var customEmailsArr = customEmails.split('~');`

Note that you may need to include the embedded data field in your survey flow for it to be accessible.

Leave a Reply