1
votes

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

1
There are CheckIn methods in both managed Client Object Model File.CheckIn and JavaScript COM SP.File.checkIn. What do you need to know exactly? What have you done so far? - Marek Grzenkowicz
Hi thanks for your reply,i wanted to do File - check in - user1481570

1 Answers

0
votes

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();