Parsing Embedded Data | XM Community
Skip to main content

Is there some way to parse or modify embedded data in a way before a user takes a survey?

In my case, I have an embedded data field that’s called OpenDate. And I use it to populate the survey.

 

It has the dates, but in this form: 4/14/2023 12:00:00 AM

I’m wondering if there is a way to remove the  12:00:00 AM and have it pipe in the date instead.

 

You can use JavaScript to do this. It should pick up your current field, remove the last part, and then store the embedded data again.

The only issue would be if you would need to use the data on the first page you display?

You access the JavaScript by clicking on the question (can even be just text/graphic) and then click on the “</> Javascript” under options.

Here you can see 3 options where to put the JavaScript, and you should add this under the addOnReady function.

It should look something like this:

Qualtrics.SurveyEngine.addOnReady(function()
{
    /*Place your JavaScript here to run when the page is fully displayed*/
    var openDate = "${e://Field/OpenDate}";  // Get the data from your field
    const newOpenDateArray = openDate.split(" "); // Split it by the space in the middle

    Qualtrics.SurveyEngine.setEmbeddedData('OpenDate',newOpenDateArray,0]); // add the first part of the text back to the field.

});

You can also download data in excel and replace this time with blank or using excel formula to show data in desired format.


@JesperAndersen  Yes I would need the data on the first page


Hi @chefthepaco ,

Can you clarify , as to how are these data's are populated.

Btw , you can still use above JS, first  create  a hidden question(This should be your first question) where you can apply the above JS  and set its value.
And from there on you can use it anywhere in the survey as the embedded data value is set.

Hope this resolves your query😊!!
 


Sure @qualtrics_nerd

Al the processes happen in the background through a couple automations I set up. One for importing contacts from a server, another for distributing the survey. The file import takes in a csv file  that’s populating embedded data fields. Since I don’t have control over how the data gets entered into the OpenDate in the csv (working to get that changed). 

But for now, I’m using the field in the first question that asks the participants about what they did on that date.

So I should create an empty question before it asking the first real question?


You should be able to create it as an introduction text, so you don’t even to show it as a question.

I’m unsure if the embedded data you use in question 2 will update, if the JavaScript is on the same page. But there would be two solutions to that:

  1. Use the JavaScript to change the value of the Question where you show the date, or
  2. Make the first question blank, put it in its own section, then add a this JavaScript to trigger the next button, so that the system loads the next page:
    this.clickNextButton()
    From the users perspective, they will just see a blank page for a split second and then the rest of the survey loads, and now the correct date can be shown.

 


Leave a Reply