Create multi line Site Column using CSOM

Create multi-line Site Column using CSOM in SharePoint Programmatically

In this post, i describe you to Create multi-line Site Column using CSOM. There is some Category in Multi-Line site column.

  • Plain text field
  • Rich text field
  • Enhanced text field

Basically, in SharePoint site column, it is known as Single Line of Text. Below is code to create a multi line of the text field. If you want to create Text Type Column then follow my post.Create Text Type Site Column using CSOM

[AdSense-A]

Plain multi-line text field

public static void Create MultilineSiteColumns(string SiteUrls, string Displayname, string Datatype,string InternalName string Descriptipn, string groupName,string ContenttypeName)
        {
            try
            {
                ClientContext clientContext = new ClientContext(SiteUrls);
                Web rootWeb = clientContext.Site.RootWeb;
                string schemaMultilineTextField = "<Field  Type='Note' Name='" + InternalName+ "' StaticName='" + Displayname + "' DisplayName='" + Displayname + "' Group='" + groupName + "'  NumLines='6' RichText='FALSE' Sortable='FALSE' />";
                rootWeb.Fields.AddFieldAsXml(schemaMultilineTextField, true, AddFieldOptions.AddFieldInternalNameHint);
                clientContext.ExecuteQuery();
            }
            catch (Exception ex)
            {
            }

        }

Rich multi-line text field

public static void Create MultilineSiteColumns(string SiteUrls, string Displayname,string InternalName string Descriptipn, string groupName,string ContenttypeName)
        {
            try
            {
                ClientContext clientContext = new ClientContext(SiteUrls);
                Web rootWeb = clientContext.Site.RootWeb;
                string schemaMultilineTextField = "<Field  Type='Note' Name='" + InternalName+ "' StaticName='" + Displayname + "' DisplayName='" + Displayname + "' Group='" + groupName + "'  NumLines='6' RichText='True' Sortable='FALSE' />";
                rootWeb.Fields.AddFieldAsXml(schemaMultilineTextField, true, AddFieldOptions.AddFieldInternalNameHint);
                clientContext.ExecuteQuery();
            }
            catch (Exception ex)
            {
            }

        }

Enhanced multi-line text field

[AdSense-A]

public static void Create MultilineSiteColumns(string SiteUrls, string Displayname, string InternalName, string Descriptipn, string groupName,string ContenttypeName)
        {
            try
            {
                ClientContext clientContext = new ClientContext(SiteUrls);
                Web rootWeb = clientContext.Site.RootWeb;
                string schemaMultilineTextField = "<Field  Type='Note' Name='" +InternalName+ "' StaticName='" + Displayname + "' DisplayName='" + Displayname + "' Group='" + groupName + "'  NumLines='6' RichText='True' RichTextMode='FullHtml' IsolateStyles='TRUE' Sortable='FALSE' />";
                rootWeb.Fields.AddFieldAsXml(schemaMultilineTextField, true, AddFieldOptions.AddFieldInternalNameHint);
                clientContext.ExecuteQuery();
            }
            catch (Exception ex)
            {
            }

        }

 


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!