Creating new list items using VS on SharePoint 2013/2010

using Microsoft.SharePoint.Client;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SPListItemCreation
{
    class Program
    {
        static void Main(string[] args)
        {
            AddGeolocationField();
            Console.WriteLine("Location field added successfully");
        }

        private static void AddGeolocationField()
        {
            // Replace site URL and List Title with Valid values.
            ClientContext context = new ClientContext("http://t-test-sp13:7777");
            List oList = context.Web.Lists.GetByTitle("RealEstates");
            oList.Fields.AddFieldAsXml("<Field Type='GMapFieldGeolocation' DisplayName='Location'/>", true, AddFieldOptions.AddToAllContentTypes);
            oList.Update();
            context.ExecuteQuery();
        }
    }
}

Comments

Popular posts from this blog

Search Service Application Error in SP2013

Errors While Importing Site Collection in SharePoint 2013/2010

Deleting Multiple Sub-sites within Site using PowerShell