Follow up Steps to create & set up Survey:-
1. First, Create & set up two custom objects in Salesforce like Training & Customer Survey.
2. Training Object is the Parent object of Customer Survey Object. (Customer Survey object is Training related object.)
3. Create Custom label :
Set up -> Search for and then select -> 'Custom Labels' -> New Custom labels.
More Details: Here
4. Write Apex, Visualforce code.
Apex : DE_TrainingSurveyController
public class DE_TrainingSurveyController {
public Customer_Survey__c cs {get;set;}
public String TrainingId {get;set;}
public String AccountId {get;set;}
public String ContactId {get;set;}
public String q4 {get;set;}
public String q5 {get;set;}
public String q6 {get;set;}
public String q7 {get;set;}
public String q8 {get;set;}
public String q9 {get;set;}
public String q10 {get;set;}
public String q11 {get;set;}
public List<Training__c> TrainingRecord {get;set;}
public String cName {get;set;}
public String AName {get;set;}
public DE_TrainingSurveyController(){
cs = new Customer_Survey__c();
TrainingId = ApexPages.CurrentPage().getParameters().get('Trainingid');
AccountId = ApexPages.CurrentPage().getParameters().get('Accountid');
TrainingRecord = [SELECT Contact_Person__r.FirstName, Account__r.Name From Training__c WHERE id =: TrainingId LIMIT 1];
if(TrainingRecord.size() > 0){
cName = TrainingRecord[0].Contact_Person__r.FirstName;
AName = TrainingRecord[0].Account__r.Name;
cs.Schools_Name__c=aname;
}
}
/* Populate List with picklist values from custom field ' Issue_Resolved__c' */
public List<SelectOption> getQ4Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Issue_Resolved__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Timing populate ----- */
public List<SelectOption> getQ5Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Timing__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* overall feedback ------ */
public List<SelectOption> getQ6Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('overall_feedback__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Activity Completion*/
public List<SelectOption> getQ7Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Activity_Completion__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Adding_Different_Kinds_Of_Questions__c*/
public List<SelectOption> getQ8Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Adding_Different_Kinds_Of_Questions__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Layout__c*/
public List<SelectOption> getQ9Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Layout__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Review_Options__c*/
public List<SelectOption> getQ10Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Review_Options__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/* Allowing_students_to_attach_their_own_wo__c*/
public List<SelectOption> getQ11Types(){
Schema.sObjectType sobject_type = Customer_Survey__c.getSObjectType();
Schema.DescribeSObjectResult sobject_describe = sobject_type.getDescribe();
Map<String, Schema.SObjectField> field_map = sobject_describe.fields.getMap();
List<Schema.PicklistEntry> pick_list_values = field_map.get('Allowing_students_to_attach_their_own_wo__c').getDescribe().getPickListValues();
List<selectOption> options = new List<selectOption>();
for (Schema.PicklistEntry a : pick_list_values) {
options.add(new selectOption(a.getValue(), a.getLabel()));
}
return options;
}
/*---------------------------------------------------------------------------*/
/*public void ErrorCS(){
List<customer_survey__c> surv = [select id, Training__r.name from Customer_Survey__c where training__c =:TrainingId ];
if(surv.size()>0 && TrainingId != null || TrainingId != ''){
system.debug('size==>'+surv);
Pagereference exid = new pagereference('/apex/DE_CustomerSurveyError');
}
} */
/*---------------------------------------------------------------------*/
public PageReference saveCS(){
Pagereference exid;
List<customer_survey__c> surv = [select id, Training__r.name from Customer_Survey__c where training__c =:TrainingId ];
if(surv.size()>0 ){
exid = new pagereference('/apex/DE_CustomerSurveyError');
}else{
cs.Issue_Resolved__c = q4;
cs.Timing__c = q5;
cs.overall_feedback__c=q6;
cs.Activity_Completion__c=q7;
cs.Adding_Different_Kinds_Of_Questions__c=q8;
cs.Layout__c=q9;
cs.Review_Options__c=q10;
cs.Allowing_students_to_attach_their_own_wo__c=q11;
cs.Training__c = TrainingId;
insert cs;
exid = new PageReference('/apex/DE_CustomerSurveyThanks');
}
return exid;
}
}
VisualForce 1: DE_TrainingSurvey.vfp
<apex:page controller="DE_TrainingSurveyController" standardStylesheets="false" showheader="false">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>{!$label.SDO_CustomerSurvey}<!--Customer Survey--></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" />
<!-- Latest compiled and minified JavaScript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<style>
body{
background: url({!$Resource.surveybackground}) 50% 50% no-repeat;
background-color: #B1BAC1;
background-size: cover;
background-attachment: fixed;
color: #fff;
font-weight: 300;
}
.container{
margin-top: 40px;
}
label, h2 {
font-weight: 300;
}
.radio input[type=radio]{
margin-left: 0px;
margin-top: 3px;
}
</style>
</head>
<div class="container">
<apex:form >
<form role="form">
<div class="form-group">
<h2>{!$label.SDO_CustomerSurvey_Thanks}<!--Thanks--> {!cName} {!$label.SDO_CustomerSurvey_Title} <!--for taking the time to fill out this quick survey.--> </h2>
<h4>{!$label.SDO_CustomerSurvey_SubTitle}<!--Your comments will help us drive important improvements in our products and services.--></h4>
</div>
<!-------------------------------------------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question1"><apex:outputText value="{!$Label.SDO_CustomerSurvey_Q1}" escape="false"/><!--1. To what extent do you agree or disagree with the following statement:<br />
The company made it easy for me to handle my issue.-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Effortless_Experience__c}" styleClass="form-control"/>
</div>
</div>
</div>
<!----------------------------------Training_Help__c----------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question2">{!$label.SDO_CustomerSurvey_Q5}<!--2. How would you rate your overall satisfaction with your customer service experience?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Training_Help__c}" styleClass="form-control"/>
</div>
</div>
</div>
<!---------------------------------------Current_Job__c-------------------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;" >
<label for="question3">{!$label.SDO_CustomerSurvey_Q6}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Current_Job__c}" styleClass="form-control"/>
</div>
</div>
</div>
<!----------------------------------Students_Report_Generation__c-------------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question2">{!$label.SDO_CustomerSurvey_Q8}<!--2. How would you rate your overall satisfaction with your customer service experience?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Students_Report_Generation__c}" styleClass="form-control"/>
</div>
</div>
</div>
<!---------------------------------Students_Essay_Type_Questions__c--------------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question2">{!$label.SDO_CustomerSurvey_Q9}<!--2. How would you rate your overall satisfaction with your customer service experience?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Students_Essay_Type_Questions__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!------------------------------------********q5.--------------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question1"><apex:outputText value="{!$Label.SDO_CustomerSurvey_Q7}" escape="false"/><!--1. To what extent do you agree or disagree with the following statement:<br />
The company made it easy for me to handle my issue.-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$Label.SDO_CustomerSurvey_Q18}
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q5}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q5Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q6------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$label.SDO_CustomerSurvey_Q19}
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q6}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q6Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q7------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$label.SDO_CustomerSurvey_Q20}<!--4. Was your issue completely resolved?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q7}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q7Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q8------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$label.SDO_CustomerSurvey_Q21}<!--4. Was your issue completely resolved?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q8}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q8Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q9------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$label.SDO_CustomerSurvey_Q22}<!--4. Was your issue completely resolved?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q9}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q9Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q10------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question4">{!$label.SDO_CustomerSurvey_Q23}<!--4. Was your issue completely resolved?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q10}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q10Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------*****q11------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12" >
<label for="question4">{!$label.SDO_CustomerSurvey_Q24}<!--4. Was your issue completely resolved?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:selectRadio value="{!q11}" styleClass="radio" layout="pagedirection">
<apex:selectOptions value="{!Q11Types}" />
</apex:selectRadio>
</div>
</div>
</div>
<!-------------------------------------Training_Requests__c------------------------------------------------>
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question3">{!$label.SDO_CustomerSurvey_Q13}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
</div>
<!---------------------------------------Live_Class__c------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question3">{!$label.SDO_CustomerSurvey_Q14}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Live_Class__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!------------------------------------Online_Test_Quiz__c------------------------------------------------------>
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question3">{!$label.SDO_CustomerSurvey_Q15}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Online_Test_Quiz__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!----------------------------------Home_Work__c----------------------------------------->
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question3">{!$label.SDO_CustomerSurvey_Q16}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Home_Work__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!------------------------------------Regrading_and_Reports__c--------------------------------------->
<div class="form-group">
<div class="column">
<div class="col-lg-12">
<label for="question3">{!$label.SDO_CustomerSurvey_Q17}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="column">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Regrading_and_Reports__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!----------------------------------Schools_Name__c----------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question3">{!$label.SDO_CustomerSurvey_Q10}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Schools_Name__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!------------------------------------Email_ID_Of_The_Teacher_Principal__c--------------------------------------->
<div class="form-group">
<div class="row">
<div class="col-lg-12" style="color:yellow;">
<label for="question3">{!$label.SDO_CustomerSurvey_Q11}<!--3. How likely is it that you would recommend this company to a friend or colleague?-->
</label>
</div>
</div>
<div class="row">
<div class="col-lg-3 col-md-4 col-sm-9 col-xs-12">
<apex:inputField value="{!cs.Email_ID_Of_The_Teacher_Principal__c}" styleClass="form-control"/><br/>
</div>
</div>
</div>
<!--------------------------------------------------------------------------->
<div class="form-group">
<apex:commandButton action="{!saveCS}" value="{!$Label.site.submit}" styleClass="btn btn-success"/>
</div>
<!--------------------------------------------------------------------------------->
</form>
</apex:form>
</div>
</apex:page>
VisualForce 2: DE_CustomerSurveyThanks.vfp
<apex:page controller="DE_CustomerSurveyController" standardStylesheets="false" showheader="false">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>{!$label.SDO_CustomerSurvey}<!--Customer Survey--></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" />
<!-- Latest compiled and minified JavaScript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<style>
body{
background: url({!$Resource.surveybackground}) 50% 50% no-repeat;
background-color: #B1BAC1;
background-size: cover;
background-attachment: fixed;
color: #fff;
}
.container{
margin-top: 40px;
}
h2{
font-weight: 300;
}
</style>
</head>
<div class="container">
<h2>{!$label.SDO_CustomerSurvey_FeedbackThanks}<!--Thank you for your feedback!--></h2>
</div>
</apex:page>
VisualForce 3: DE_CustomerSurveyError.vfp
<apex:page controller="DE_CustomerSurveyController" standardStylesheets="false" showheader="false">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>{!$label.SDO_CustomerSurvey}<!--Customer Survey--></title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css" />
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap-theme.min.css" />
<!-- Latest compiled and minified JavaScript -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js"></script>
<style>
body{
background: url({!$Resource.surveybackground}) 50% 50% no-repeat;
background-color: #B1BAC1;
background-size: cover;
background-attachment: fixed;
color: #fff;
}
.container{
margin-top: 40px;
}
h2{
font-weight: 300;
}
</style>
</head>
<div class="container">
<h2>{!$label.SDO_CustomerSurveError}<!--Error for your feedback!--></h2>
</div>
</apex:page>
5. Create Site:
Set up -> Search for and then select -> 'Sites' -> Register Domain Name -> then Click New
Note*: Point 3 in Screenshot, to click on 'View' than New tab open in a new browser window then to copy the URL.
Secondly, To create the 'Survey_Web__c' Name field on training Object & in this field to set by default value --> "URL"
More Details:- Here
6. Create Custom (Without Using Classic Letterhead).
<a href="{!Training__c.Survey_Web__c}?Trainingid={!Training__c.Id}">Customer Experience Survey </a>
7. At Last, Set up Process Builder like After Training Completed Automatic Survey Mails goes to Contact Person.
8. Finally, Completed all 1-7 steps then you can start your training. And After Completed training automatic survey mail goes to the 'Contact Person' Email ID.
*This Person to fillup the survey form at a time. Like:-
* Again, you fill-up the form than to show an error message like:-
0 Comments