Create Text Type Site Column using CSOM

Create Text Type Site Column using CSOM in SharePoint Programmatically

In this post, I describe you to Create Text Type Site Column using CSOM. Basically, in SharePoint site column it is known as Single Line of Text. Below is code to create a single line of text field. If you want to create Multi Line site column then follow my post. Create multi line Site Column using CSOM[AdSense-A]

public static void CreateTextTypeSiteColumns(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;
                rootWeb.Fields.AddFieldAsXml("<Field DisplayName='" + Displayname + "' Description='" + Descriptipn + "' Name='" + InternalName + "' Group='" + groupName + "' Type='Text' />", false, 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 !!