Question

The nice response when a user tries to answer a survey twice is the message: "You are not allowed to respond again to this survey." But some of us are getting the standard "crash" screen for ASP.NET applications.

Is this a configuration item or something (we're on SP2007)?

Thanks in advance...

Was it helpful?

Solution

I ended up getting around this problem by completely substituting the default "Respond to..." button handler with this code, which replaces any attempt to re-take the survey with an alert informing the user he's done it already.

$(document).ready(function() {  
    var myQueryOptions = "<QueryOptions />";
    //this was amazing: the value you need gets supplied by <UserID Type='Integer'/> (via Vadim Gremyachev)
    var myQuery = "<Query><Where><Eq><FieldRef Name='Author'/><Value Type='Integer'><UserID Type='Integer'/></Value></Eq></Where></Query>"; //find any instance of the current user
    var listPromise = $().SPServices({
        operation:  "GetListItems",
        listName: "{58ECDD94-8817-43A9-ACEC-42A1657E2F25}", //dev  Survey list
        CAMLViewFields: "<ViewFields><FieldRef Name='ID' /></ViewFields>",
        CAMLQuery: myQuery,
        CAMLQueryOptions: myQueryOptions
    });
    listPromise.done(function() {
        var iCount = $(listPromise.responseXML).SPFilterNode("rs:data").attr("ItemCount");
        if(iCount > 0) {
            $("[id*='_ctl00_toolBarTbl_RptControls_ctl00_diidIONewItem']").each(function() {
                $(this).attr("onclick", "");
                $(this).attr("href", "");
                $(this).on("click", function() {alert("You've already taken the survey!");});
            });
        }
        iCount++;
    });
    listPromise.fail(function() { alert("whoops");});
}); // $(document).ready()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top