Hi. I'm trying to get respondents to enter in their ID but only wish to store a SHA-256 hash of the ID. Hence I've created a HTML form input and save it to embedded data. I've been successful setting embedded data in addOnload or addOnReady but when setting the embedded data in a promise, the data will not be stored even when attempted to getEmbeddedData retrieves the right value. Any advise?
Qualtrics.SurveyEngine.addOnload(function()
{
/*Place your JavaScript here to run when the page loads*/
function hex (buff) {
return [].map.call(new Uint8Array(buff), b => ('00' + b.toString(16)).slice(-2)).join('');
}
Qualtrics.SurveyEngine.addOnPageSubmit(function(type)
{
if(type == "next")
{
var userID = document.getElementById('QNRIC').value;
window.crypto.subtle.digest('SHA-256', new TextEncoder().encode(userID))
.then((val)=> {
//alert(hex(val))
Qualtrics.SurveyEngine.setEmbeddedData("hashNRIC",hex(val));
alert(Qualtrics.SurveyEngine.getEmbeddedData("hashNRIC"));
});
}
});
Question
Setting Embedded Data
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.
