Programmatically mask the created by and modified by in the SharePoint list edit and display forms


In this article we will be seeing how to mask the created by and modified by in the SharePoint list edit and display forms as shown in the following

PShare1.gif

Using C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using System.Xml;

namespace MaskUser
{
    class Program
    {
        static void Main(string[] args)
        {
            using (SPSite site = new SPSite("http://serverName:1111/"))
            {
                using (SPWeb web = site.RootWeb)
                {                 
                    SPList list=web.Lists["cl"];
                    list.ShowUser = false;            
                    list.Update();
                }
            }
        }
    }
}


Using PowerShell:

$site=Get-SPSite "http://serverName:1111/"
$web=$site.RootWeb
$list=$web.Lists["cl"]
$list.ShowUser=$false
$list.Update()

Up Next
    Ebook Download
    View all
    Learn
    View all