1

can you please advise me as how to create checkin checkout functionality in file under document library using client object model in SharePoint 2010

thanks kajal

user1481570
  • 21
  • 2
  • 7
  • There are CheckIn methods in both managed Client Object Model [File.CheckIn](http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.client.file.checkin.aspx) and JavaScript COM [SP.File.checkIn](http://msdn.microsoft.com/en-us/library/ee658535.aspx). What do you need to know exactly? What have you done so far? – Marek Grzenkowicz Jul 05 '12 at 10:00
  • Hi thanks for your reply,i wanted to do File - check in – user1481570 Jul 05 '12 at 14:53

1 Answers1

0

Everytime you do createion, deleteion or updating metadata in SharePoint Files,

you are suggested to do check out before the operation and check in after the operation.

=======================================

//Check Out

clientContext = new Microsoft.SharePoint.Client.ClientContext("Your site here");

clientContext.Credentials = new NetworkCredential("LoginID","LoginPW", "LoginDomain");

clientContext.Load(clientContext.Web);
Microsoft.SharePoint.Client.Web web = clientContext.Web;

Microsoft.SharePoint.Client.File f = web.GetFileByServerRelativeUrl("relative path to the file");

f.CheckOut();

clientContext.ExecuteQuery();

//....... Your operation...............

//Check in

clientContext.Credentials = new NetworkCredential("LoginID","LoginPW","LoginDomain");

clientContext.Load(clientContext.Web);

Microsoft.SharePoint.Client.Web web = clientContext.Web;

Microsoft.SharePoint.Client.File f = web.GetFileByServerRelativeUrl("relative path to the file");

f.CheckIn(String.Concat("File CheckingIn at ", DateTime.Now.ToLongDateString()), 
Microsoft.SharePoint.Client.CheckinType.MajorCheckIn);

clientContext.ExecuteQuery();
Tony Wu
  • 1,040
  • 18
  • 28