Web View Steps
Web View steps allow you to present customized steps within a MyDataHelps survey. Although you can use most SDK methods from Web View steps, these methods are specifically used to control the logic of your custom step.
Complete a Web View Step
MyDataHelps.completeStep(optionalAnswerText)
Complete the current survey step. If called with a parameter, that parameter is saved as the answer for the step. If no parameter is supplied, then an empty string is saved as the answer. You can also store structured data such as JSON, as long as it’s formatted as a string. See Saving Survey Results for details.
Parameters
answerText
string
The single answer to record for this step. If omitted, an empty string is recorded as the answer for the step.
Availability
<script type="text/javascript">
function next() {
var element = document.getElementById("StepInput");
var answerText = element.value;
MyDataHelps.completeStep(answerText);
}
function skip() {
MyDataHelps.completeStep();
}
</script>
<input type="text" id="StepInput" placeholder="Answer text" />
<button onclick="next()">Next</button>
<button onclick="skip()">Skip</button>
Get Current Survey Answers
MyDataHelps.getCurrentSurveyAnswers()
Used within a Web View step to retrieve the participant’s responses to other Question, Form, Consent, or Web View steps within the current survey.
Returns
Promise<CurrentSurveyAnswers[]>
Resolves to a results
collection containing a list of current survey answers.
+ Results Fields
results[n].date
date
Date/time of when the question was answered.
results[n].stepIdentifier
string
The step identifier from the survey designer.
results[n].resultIdentifier
This will usually be the same as the step identifier, but for form steps it will be the identifier of the specific form question.
results[n].answers
varies
Availability
MyDataHelps.getCurrentSurveyAnswers()
.then( function(result) {
console.log(result);
} );