2

クライアントオブジェクトモデルを使用してSharePointカレンダーイベントを作成しようとしています。「EndDate」列を除くすべての列でアイテムを作成し、列の値を設定できます。この列を設定しようとすると、次のエラーが表示されます。ドイツ語からのメッセージの翻訳は「リストエントリの更新中に無効なデータが使用されています。更新するフィールドは書き込み保護されている可能性があります。」です。この列をスキップすると、Sharepointサーバーで作成されたアイテムをenddateプロパティなしで一覧表示しますが、カレンダービューには表示されません。「datasheetview」タイプのビューでアイテムを見ることができます。ここから終了日を設定すると、カレンダービューでも表示されます(奇妙なことに、必須フィールドです)。

Server Exception Microsoft.SharePoint.Client.ServerException was unhandled.    Message=Es wurden ungültige Daten zur Aktualisierung des Listeneintrags verwendet. Das Feld, das Sie aktualisieren möchten, ist möglicherweise schreibgeschützt.   Source=Microsoft.SharePoint.Client.Runtime   ServerErrorCode=-2147024809   ServerErrorTypeName=System.ArgumentException   ServerStackTrace=""   StackTrace:  
       at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)  
    at Microsoft.SharePoint.Client.ClientRequest.ProcessResponse()  
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQueryToServer(ChunkStringBuilder sb)  
       at Microsoft.SharePoint.Client.ClientRequest.ExecuteQuery()  
       at Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQuery()  
       at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()  
       at Sp_Ctx.Program.Main(String[] args) in_Ctx\Program.cs:line 129   InnerException:   

私のコードは次のとおりです

using (ClientContext ctx = ClaimClientContext.GetAuthenticatedContext(targetSite)){ if (ctx != null)   {  
ctx.Load(ctx.Web); // Query for Web  

    ctx.ExecuteQuery(); // Execute  
            Console.WriteLine(ctx.Web.Title);  
            List list = ctx.Web.Lists.GetByTitle("calendarListName");  
            ctx.Load(list.Fields);  
            ctx.ExecuteQuery();  
            var newItem = list.AddItem(listItemCreationInfo);  
            newItem.Update();           
            newItem["Title"] = "myCalendar"   ..... 
            newItem["EventDate"]= DateTime.Now;  
            newItem["EndDate"]= DateTime.Now.AddMinutes(30);  
            newItem["Location"]= "Office";  
            newItem.Update();  
            ctx.ExecuteQuery();

}
4

1 に答える 1

1

答えは、イベントの日付と終了日を一緒に更新するだけでした。元の解決策はここで見ることができます

于 2012-07-25T11:12:07.663 に答える