Hide columns in list using client side object model in SharePoint

Advertisement
We are having a requirement to hide the unwanted columns in the NewForm.aspx and EditForm.aspx using client side object model.
We are using the Properties SetShowInNewForm, SetShowInEditForm to hide the fields in a particular list, if you want to show it again change it to (true)


using Microsoft.SharePoint;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace hidecolumns
{
    class Program
    {
        static void Main(string[] args)
        {
            ClientContext clicon = new ClientContext("http://dotnetsharepoint.com/sites/SharePoint");
            List list =clicon.Web.Lists.GetByTitle("yourlistname");
            clicon.Load(list);
            list.Fields.GetByInternalNameOrTitle("YourColumnName").SetShowInNewForm(false);
            list.Fields.GetByInternalNameOrTitle("YourColumnName").SetShowInEditForm(false);
            clicon.ExecuteQuery();
            list.Update();
      
        }
    }

}

SharePoint Online Real Time Training Contact: JLAKSHMITULASI@GMAIL.COM
Advertisements
SHARE

Lakshmi Tulasi Jasti

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment