Need solution for a unique problem | XM Community
Solved

Need solution for a unique problem

  • 13 June 2018
  • 2 replies
  • 14 views

I am creating a pre-screener where we are receiving ids in a unique format e.g. vbd155727_hgdsjSGdsuyegwuahs , I want to know if its possible for me to trim vbd155727_ and just send hgdsjSGdsuyegwuahs into my client link at the time of final redirection under a specific variable.
icon

Best answer by Rich_Boits_Walker 13 June 2018, 21:49

View original

2 replies

Userlevel 6
Badge +5
Hi @KGParadigm , I found this on a previous post and it may be what you are looking for. It allowed me to create an ED field that only contained a certain range of characters from a field.

Replace "ResponseID with the field you want. Replace the "13" and "18" with the character ranges you want to send. Replace "PatientID" with the name of the new ED field you want. Hope this helps!

`Qualtrics.SurveyEngine.addOnReady(function()
{
/*Place your JavaScript here to run when the page is fully displayed*/
var str = " ${e://Field/ResponseID}";
var res = str.substr(13,18);
Qualtrics.SurveyEngine.setEmbeddedData("PatientID", res);
});`
Userlevel 5
Badge +7
Hey @KGParadigm, here's how I think I'd tackle this using a `split()`.

Qualtrics.SurveyEngine.addOnload(function()
{
// get data from an embedded data field names LinkID
var fullLinkID = "${e://Field/LinkID}";

// split the data based on your '_' formatted string and trim it
var myLinkID = fullLinkID.split("_")[1];

// overwrite your embedded data field with your new cleaned up string ID
Qualtrics.SurveyEngine.setEmbeddedData("LinkID",myLinkID);
});

Then on your client link URL redirect you would append `${e://Field/LinkID}`

Leave a Reply