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();
}
}
}
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
Post a Comment