Show SharePoint Survey Friendly message using jQuery

show friendly message survey sharepoint 2013
InfoPath alternatives for form designing SharePoint

Once we submit the survey response, still it allows to click on respond survey link but after this it displays an ugly message.

show friendly message survey sharepoint 2013
show friendly message survey sharepoint 2013

I had a requirement where the Survey Link was set in tiles web part and we had to display custom message if the survey has been already submitted.

show friendly message survey sharepoint 2013
show friendly message survey sharepoint 2013

Also check out:
– Content Query web part Group by Column in Office 365

– How to get list item attachments using JavaScript client object model?

– Design Manager in SharePoint 2013

Please find the below code to achieve the requirement. Create .js file and place the code, make sure you change the Tile Div ID according to your client id.

Provide the .js file refernce in the page where Survey link has been provided.

var linkTitle;
var linkOrginal;
var linkMessage;
$(document).ready(function ()

SP.SOD.executeFunc(‘sp.js’, ‘SP.ClientContext’, function () {

$(‘a[id^=Tile_WPQ]’).click(function(e) {
linkTitle = $(this).attr(“id”);
linkOrginal= $(this).attr(‘href’);
if (linkTitle == “Tile_WPQ10_1_3”)


var collListItems ;
var currentUser = null;
var web;
var context;
var list;
var viewXml;
var query;
function getWebSiteData() {

context = new SP.ClientContext.get_current();
web = context.get_web();
currentUser = web.get_currentUser();

list = web.get_lists().getByTitle(‘Survey’);
var query= new SP.CamlQuery();
query.set_viewXml(‘<View><Query><Where><Eq><FieldRef Name=\’Author\’ LookupId=\’TRUE\’ /><Value Type=\’Integer\’><UserID /></Value></Eq></Where></Query></View>’);

collListItems = list.getItems(query);
Function.createDelegate(this, this.onSuccessMethod),
Function.createDelegate(this, this.onFailureMethod));
//context.executeQueryAsync(Function.createDelegate(this, this.onSuccessMethod), Function.createDelegate(this, this.onFailureMethod));
function onSuccessMethod(sender, args)
var votesCount = this.collListItems.get_count();
if(votesCount > 0)
// window.alert(‘You have already voted to this survey.’);
// + ‘/Pages/Survey-Message.aspx’);
window.location.href = this.web.get_url()+ ‘/Pages/Survey-Message.aspx’;

else {

function onFailureMethod(sender, args) {
alert(‘request failed ‘ + args.get_message() + ‘\n’ + args.get_stackTrace());

Similar SharePoint 2013 Tutorials

About Sambita Rath

I have 9 years of exprience into SharePoint implementation, architecture, Administrator, development and Training.Designing Information Architecture in SharePoint 2007, 2010,2013 and Office 365.

View all posts by Sambita Rath →

Leave a Reply