Convert imported file into an array accessed in JavaScript code block | XM Community
Skip to main content
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.
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