ui.survey.Survey Class
Create a survey instance
Constructor
ui.survey.Survey
(
-
config
Parameters:
-
config
ui.survey.SurveyConfigA ui.survey.SurveyConfig class to configure this instance and all subsequent survey calls
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
Item Index
Methods
getResponseId
()
String
Returns the response ID for this survey isntance.
Returns:
String:
The response ID set for this survey instance
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
var responseId = survey.getResponseId();
getSurveyData
(
Promise
-
[requestConfig=""]
Get survey data
Parameters:
-
[requestConfig=""]
ui.survey.SurveyRequestConfig optionalrequestConfig A ui.survey.SurveyRequestConfig object
Returns:
Promise:
A promise that resolves to a ui.survey.SurveyModel object when response has been received
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
var requestConfig = {
"preview": true // Optional Set to true to return preview survey data
"surveyPlatformHostName": "survey.com" // Optional hostname for the survey platform
};
// config is optional
survey.getSurveyData(requestConfig).then(
function(data) {
console.log("Survey data loaded. See survey platform documentation for details");
},
function(err) {
console.log(err);
});
logOfferResponse
(
-
offerState
Log a survey offer
Parameters:
-
offerState
StringThe ui.survey.OfferState offer state
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
survey.logOfferResponse(window.MsSupportSdk.ui.survey.OfferState.DISPLAYED);
logSurveyResponse
(
-
config
Log a survey response
Parameters:
-
config
ui.survey.surveyResponseConfigA ui.survey.SurveyResponseConfig object
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
// Log a survey response. It is suggested you first get the survey before logging a response
var config = {
"mode": "mode", // Mode of the submitted survey (from the survey platform)
"quality": "good" // Quality of the submitted survey. poor | good. Set to poor to ignore the data during reports.
"type": "site" // Type of the survey. site | email
"locale": "en-us", // Locale of the submitted survey
"isPartialResponse": true, // Set to true if the survey is partially completed. Otherwise set to false
"displayTime": 2017-07-14T22:29:37.714Z, // Time the survey was displayed to the user (NOT the current time)
"partnerContext": "{c1:true}", // Partner context data (any JSON KVP)
"surveyResponse": [{ // A collection of {{#crossLink "ui.survey.SurveyQuestionConfig"}}
"questionId": 1, // ID of the submitted question (from the survey platform)
"questionDisplayIndex": 0, // 0 based index of the question display order
"questionCategory": "CSAT", // Category of the question (from the survey platform)
"percannedResponse": 0, // either a precanned response (preset ID for an option from the survey platform)
"verbatim": "Your site rules", // or a verbatim response (freeform text) should be provided
]}
};
survey.logSurveyResponse(config);
render
(
Promise
-
config
Render the Survey UI
Parameters:
-
config
ui.survey.ConfigA ui.survey.Config object
Returns:
Promise:
A promise that resolves to a ui.survey.SDK object when the UI component has successfully loaded
Example:
var surveyConfig = {
"surveyId": "integrationsurvey",
"locale": "en-us"
};
var survey = window.MsSupportSdk.ui.survey.createSurvey(surveyConfig);
// Please handle survey offers in addition to this
var surveyRenderConfig = {
"preview": false,
"viewMode": "wizard",
"environment": "https://survey.support.services.microsoft.com/viewsurvey.html",
"surveyPlatformEnvironment": "production",
"uiInfo": {
"type": 1,
"containerSelector": "#iframe_container"
}
};
survey.render(surveyRenderConfig);