How to set SharePoint “Author” in silverlight clie

2019-07-16 14:29发布

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

        }

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.

1条回答
beautiful°
2楼-- · 2019-07-16 14:52

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

 listItem["Author"] = 8;
 listItem["Editor"] = 11;
查看更多
登录 后发表回答