locked
Prevent users from changing name of Wiki page? RRS feed

  • Question

  • Hi there,

    Is there a way to prevent users from changing the name of a Wiki page in Sharepoint?

    Thanks

    Thursday, April 26, 2012 10:29 AM

Answers

  • Hi,

    The most simplest way will be to modify EditForm.Aspx in your wiki pages librray and remove the field Title from it so that if someone tries for it there will be no option to change this.


    Thanks, Rahul Rashu

    Saturday, April 28, 2012 3:30 AM
  • The purpose can be solved with the help of event receiver on your wiki library.

    You can hook into the ItemUpdating event for the wiki library and prevent a user from changing a certain column with the help of the following code snippet:

    public override void  ItemUpdating(SPItemEventProperties properties)
    {
        if (properties.BeforeProperties["LinkFilename"] != properties.AfterProperties["LinkFilename"])
        {
            properties.Cancel = true;
            properties.ErrorMessage = "The name of this Wiki page cannot be changed!";
        }
    }

    In the above code snippet, "LinkFilename" is the internal name of the Name field of the Wiki page. Here we are comparing the BeforeProperties and AfterProperties of the current item to determine whether the value of the column has changed or not. And depending on that condition, we cancel the update process and display appropriate error message to the end-user.

    Hope this helps. Happy Coding!


    Saturday, April 28, 2012 12:24 PM

All replies

  • Out of the box, I havn't seen any way to prevent users from changing the wiki page name.  If they can edit the item, they have permission to all of the exposed fields.

    "There is always a way"

    You might try an event receiver on the wiki library which checks to see if the user has a custom permission level (which you predefined). If so, page name changes will go through, otherwise the user would be prompted with an error saying something like 'You do not have permission to rename this page'.  This would require you to have some programing experience, but there are plenty of code samples for this sort of thing out there.


    Thursday, April 26, 2012 10:33 PM
  • Hi,

    The most simplest way will be to modify EditForm.Aspx in your wiki pages librray and remove the field Title from it so that if someone tries for it there will be no option to change this.


    Thanks, Rahul Rashu

    Saturday, April 28, 2012 3:30 AM
  • The purpose can be solved with the help of event receiver on your wiki library.

    You can hook into the ItemUpdating event for the wiki library and prevent a user from changing a certain column with the help of the following code snippet:

    public override void  ItemUpdating(SPItemEventProperties properties)
    {
        if (properties.BeforeProperties["LinkFilename"] != properties.AfterProperties["LinkFilename"])
        {
            properties.Cancel = true;
            properties.ErrorMessage = "The name of this Wiki page cannot be changed!";
        }
    }

    In the above code snippet, "LinkFilename" is the internal name of the Name field of the Wiki page. Here we are comparing the BeforeProperties and AfterProperties of the current item to determine whether the value of the column has changed or not. And depending on that condition, we cancel the update process and display appropriate error message to the end-user.

    Hope this helps. Happy Coding!


    Saturday, April 28, 2012 12:24 PM