Saturday, October 20, 2012

Update Shared Document Custom Fields Using Client Object Model in SharePoint 2010


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Client;
using SP = Microsoft.SharePoint.Client;

namespace MYItemUpdate
{
    class Program
    {
        static void Main(string[] args)
        {
            getfiles();
        }

        private static void getfiles()
        {
            ClientContext clientContext = new ClientContext("http://server-sp:6677/sites/HRDocuments/");
            clientContext.Credentials = new System.Net.NetworkCredential("username1""pass@1234","myDomineName1");
            List list = clientContext.Web.Lists.GetByTitle("Shared Documents");
            CamlQuery camlQuery = new CamlQuery();
            camlQuery.ViewXml = @"<View Scope='Recursive'></View>";

            camlQuery.FolderServerRelativeUrl = "/sites/HRDocuments/Shared Documents/Pay Slips";

            SP.ListItemCollection listItems = list.GetItems(camlQuery);
            clientContext.Load(listItems);
            clientContext.ExecuteQuery();

            SP.ListItem itemOfInterest = listItems[0];
            Console.WriteLine(itemOfInterest["Employee_x0020_ID"].ToString());
            itemOfInterest["Employee_x0020_ID"] = "66";
            itemOfInterest.Update();
            clientContext.ExecuteQuery();

            listItems = list.GetItems(camlQuery);
            clientContext.ExecuteQuery();

        }
    }
}

1 comment:


  1. Many innovative printing techniques have emerged in recent years, revolutionizing the customization industry. One notable example is the rise of Zizo DTF, which offers high-quality direct-to-film printing solutions. This technology allows for vibrant and durable designs on a variety of fabrics, making it a favorite among small business owners and hobbyists alike. As the demand for personalized products increases, companies like Zizo DTF continue to lead the way with their advanced printing options.

    ReplyDelete

Featured Post

How to Get Table → Security Role Mapping in Power Platform (PowerShell + Web API)

How to Get Table → Security Role Mapping in Power Platform Power Platform   |   Dataverse   |   Security & Governance   When a...

Popular posts