Can I write javascript in the embedded data? | XM Community
Skip to main content
Question

Can I write javascript in the embedded data?

  • April 13, 2020
  • 6 replies
  • 16 views

Forum|alt.badge.img+1

I need to ask Qualtircs to random generate integers within a range but all integers appear in a equal probability. If I use the the web-service: set embedded data->custom value->insert pip text->random number, the probability of each integer appearing is not equal. I am wondering if I can write my own java code to generate?
Or I just want to know, how can I achieve this: generate integers within a range in embedded data, and each integer appears in equal chance?
Thanks a lot!!!!!

6 replies

TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 13, 2020

You can use Math.random().


Forum|alt.badge.img+1
  • Author
  • April 14, 2020

Can I write javascript in the embedded data?Thanks Tom! My difficulty is actually, how can I write the js in embedded data. I did not find the option to insert my own code in the embedded data block. Could you share me some guides?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 14, 2020

You can't run JS from the survey flow. The survey flow is server side, and JS is client side. If you are looking for an alternative way to generate random numbers in the survey flow, write your own web service script to do it.


Forum|alt.badge.img+1
  • Author
  • April 14, 2020

Can I write javascript in the embedded data?can I do that as an individual user? or I need to buy any license?


TomG
Level 8 ●●●●●●●●
Forum|alt.badge.img+27
  • Level 8 ●●●●●●●●
  • April 14, 2020

You need a web server to host the script.


Forum|alt.badge.img+1
  • Author
  • April 14, 2020

Can I write javascript in the embedded data?after that, how can I put it in the embedded fields? insert pip text->opt out link?
Thanks!