如何设置 SharePoint“作者"在 Silverlight 客户端对象模型中? [英] How to set SharePoint "Author" in silverlight client object model?

查看:31
本文介绍了如何设置 SharePoint“作者"在 Silverlight 客户端对象模型中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为 SharePoint 2010 开发 Silverlight Web 部件.我想在我的代码中设置 ListItem 的作者".所以我使用以下代码

I am developing a Silverlight web part for SharePoint 2010. I want to set the "Author" of ListItem in my code. So I am using the following code

  internal void Save()
        {

            ClientContext context = ClientContext.Current            

            List list = context.Web.Lists.GetByTitle("Time Log");

            ListItem listItem = list.AddItem(new ListItemCreationInformation());
            listItem["Client"] = Client.Id;
            listItem["EventDate"] = StartDateTime;
            listItem["EndDate"] = EndDateTime;
            listItem["Service"] = ClientService;
            listItem["Description"] = Description;

            listItem["Author"] = "shailesh";
            listItem["Editor"] = "shailesh";

            listItem.Update();

            context.ExecuteQueryAsync(Success, Fail);

        }

当我使用此代码时,它进入方法失败",因为行 listItem["Author"] = "shailesh";.我已经读到我们可以使用 ClientContext 的凭据属性在托管客户端对象模型中执行此操作.但看起来在 Silverlight 客户端对象模型中无法设置作者".你能告诉我们可以设置作者"的任何其他方式吗?

When I use this code it goes into the method "Fail" because of line listItem["Author"] = "shailesh";. I have read that we can do it in managed client object model using credential property of ClientContext. But it looks like that there is no way of setting "Author" in Silverlight client object model. Can you please tell any other way from which we can set the "Author" ?

如果有任何方法请提出建议,如果可能,请提供一些代码或提供一些有用的链接.

If there is any way please suggest it and if possible please provide some code or give some useful link.

推荐答案

您应该插入用户 ID 而不是登录名.例如:

You should insert user ID instead of login name. For example:

 listItem["Author"] = 8;
 listItem["Editor"] = 11;

这篇关于如何设置 SharePoint“作者"在 Silverlight 客户端对象模型中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆