Showing posts with label SharePoint. Show all posts
Showing posts with label SharePoint. Show all posts

Thursday, July 26, 2018

Make all SharePoint Surveys truly anonymous real quick

If you have worked withe surveys, you must be knowing survey provide an option "Show user names in survey results", to make survey anonymous, If not you could refer this. Now the problem with this is anyone with rights to edit list settings could change this setting and all users would be visible. 

There is no suggested approach to do this there are lots of options available. One very nice article is available on this msdn blog. Mostly suggested changing the name using event receiver or workflows. But none of these serve my purpose, as i needed to make all the surveys on the farm anonymous including the new ones. Also with hundreds of surveys across the farm, these workflows or event receivers could hamper performance.
So, i did a small trick to make sure no one to change the list setting and rest SharePoint could handle automatically.
I made some tweaking in the application page witch impacted all my surveys. We could also do the same for a particular site.
We will have to make changes in two application pages, available in layouts folder of 15 hive. Combined these changes will give an effect to of no in survey setting.
  1. ListGeneralSettings.aspx : This page opens when we click "ListName, Description, Navigation in site settings.
  1. New.aspx : This page opens when we create a new survey list. Page URL is same for both popup and advanced options page.
  1. To make sure user can not select yes on advanced options screen. To do this find the below ts tag and comment it.
  1. <td class="ms-authoringcontrols" nowrap="nowrap"><input id="onetidShowUserNamesNo" type="radio" value="on"  name="showUsernames" title="<SharePoint:EncodedLiteral runat='server' text='<%$Resources:wss,lstsetng_showusernamesyes_title%>' EncodeMethod='HtmlEncode'/>" /><label for="onetidShowUserNamesYes"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_showusernamesyes_label%>" EncodeMethod='HtmlEncode'/></label></td>
  1. By pass the Basic creation popup and navigate to advanced screen because by default SharePoint consider it yes. To do this:
  1. Find the below code in the file:
x





ListGeneralSettings:
Search for "Survey Settings" and make radio button with id "RADShowUserYes" hidden by adding attribute visible:false. This will hide the yes option in List settings.

New.aspx: We will make two changes in this file.
if (this.IsDialogMode){
    %><a class="ms-textSmall" href="javascript:;" onclick="NavigateToFullPage()"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_advancedoptions_text%>" EncodeMethod='HtmlEncode'/></a><%}

    and another if condition inside this if. Final code should look like this:

    if (this.IsDialogMode)
    {
    if (HttpContext.Current.Request.Url.AbsoluteUri.Contains("ListTemplate=102"))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "NavigateToFullPage()", true);
            }else { 
    %>
    <a class="ms-textSmall" href="javascript:;" onclick="NavigateToFullPage()"><SharePoint:EncodedLiteral runat="server" text="<%$Resources:wss,lstsetng_advancedoptions_text%>" EncodeMethod='HtmlEncode'/></a>
    <%
            }}

    If you have any existing survey lists, you could use powershell to to change their list setting.

    How to Enable Share-point Designer in Central Admin

    Below are steps for SharePoint Designer settings in Central Admin:

    1. Open Central Application Website.
    2. Open SharePoint Designer Settings under General Application Settings.
    3. Select your web application from the drop down at the top of the form.
    4. Select the appropriate options as mentioned below(per your needs) and click  ok.
    There are four check boxes as listed below:

    Enable SharePoint Designer : This Enables or disables SharePoint Designer for the Web Application and all of its site collections.

    Note: If unchecked, users still see SharePoint Designer buttons in the browser, but when they click them, they get a message stating that SharePoint Designer is not allowed on the site.

    Enable Detaching Pages from the Site Definition : This option enables or disables the ability to detach pages from the site definition. If unchecked, SharePoint Designer only allows you to edit pages in normal mode. The Edit File in Advanced Mode is disabled. Running in Advanced mode lets a user ghost pages by modifying them from the content originally in the site definition stored on the server’s hard drive. The customized version of the page is stored in the SharePoint content database. Any changes made to the site definition files aren’t reflected in detached pages. This can create maintainability problems and should be used with care.

    Note: This setting does not apply to pages that have already been detached as well as new blank ASPX or HTML pages created by the user.

    Enable Customizing Master Pages and Layout Pages : This enables or disables the ability to customize master pages and page layouts. If unchecked, SharePoint Designer does not display Master Pages or Page Layouts in the Navigation pane.

    Note: Page layouts also require publishing enabled on the server, so if you have enabled it here but the site is not a publishing site, you will still not see the Page Layouts option in the Navigation pane.

    Enable Managing of the Web Site URL Structure: This enables or disables the ability to view and edit files in the URL structure of a site. If unchecked, SharePoint Designer does not display the All Files option in the Navigation pane.


    Note: These four options are also available at site collection settings.
    If you liked the post, please share it.
    Subscribe to your email and receive new articles on your email