Piped Text Help! Pipe Specific Section | XM Community
Skip to main content
Solved

Piped Text Help! Pipe Specific Section

  • February 26, 2024
  • 5 replies
  • 60 views

Forum|alt.badge.img+5

Hello

Hope everyone is well.

In a survey question I ask for a URL.

The URL will always end with 8 digits, for example...

/12345678

How can I pipe just the 8 digits into a forthcoming question in the same survey.

Thanks :) 🤞

 

Best answer by ahmedA

Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();
const inputBox = qc.querySelector(".InputText");

inputBox.oninput = function (ev) {
const text = ev.target.value;
const last8 = text.slice(text.length - 8);
Qualtrics.SurveyEngine.setEmbeddedData("last8", last8);
};
});

 

5 replies

Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2050 replies
  • Answer
  • February 26, 2024
Qualtrics.SurveyEngine.addOnReady(function () {
const quest = this;
const qc = quest.getQuestionContainer();
const inputBox = qc.querySelector(".InputText");

inputBox.oninput = function (ev) {
const text = ev.target.value;
const last8 = text.slice(text.length - 8);
Qualtrics.SurveyEngine.setEmbeddedData("last8", last8);
};
});

 


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2050 replies
  • February 26, 2024

You can access it using the ED last8


Forum|alt.badge.img+5
  • Author
  • Level 5 ●●●●●
  • 157 replies
  • February 26, 2024

Amazing, thanks :)


Forum|alt.badge.img+5
  • Author
  • Level 5 ●●●●●
  • 157 replies
  • March 1, 2024

Hi @ahmedA 

This has been working well, thanks so much!

I want to do exactly the same as the above, but this time just pipe forward how ever many digits (will always be numbers) are at the end of a URL. The digits will also follow after a;

/

Hope you can help again! 🥷

Thanks :)


Forum|alt.badge.img+22
  • Level 7 ●●●●●●●
  • 2050 replies
  • March 1, 2024

Change the last8 line to: 

const last8 = text.split("/")[text.split("/").length - 1];