SharePoint 2010 - 客户端对象模型 - 批准文件

时间:2010-06-15 16:27:08

标签: sharepoint-2010

有人知道客户端对象模型中SPFile.Approve()方法的替换是什么吗? Microsoft.SharePoint.Client.File类没有此方法。

2 个答案:

答案 0 :(得分:6)

//upload file to document library
Microsoft.SharePoint.Client.File newFile = docs.RootFolder.Files.Add(fci);
//if target doclib has versioning enabled you will not be able to modify the Approval Status until file is checked in.
newFile.CheckIn("Programmatically Checked In", CheckinType.MajorCheckIn);
context.Load(uploadFile);
context.ExecuteQuery(); 

//get the File's underlying ListItem object
ListItem item = uploadFile.ListItemAllFields;
//use SPModerationStatusType
item["_ModerationStatus"] = SPModerationStatusType.Approved;
item.Update();
context.Load(item);
context.ExecuteQuery();

答案 1 :(得分:2)

试试这个:

item.set_item('_ModerationStatus', 0);
item.update();
context.load(item);
context.executeQueryAsync(successFunction, failureFunction);

它在一个简单的场景中适合我。