Domanda

I am trying to create a sharepoint calendar event using client object model. I can create item and set column values all columns except "EndDate" column. When I try to set this column I get the following error Translation of message from German is "Invalid data is used while updating list entry. The field you want to update is possibly write protected." If skip this column, list item created at Sharepoint server without enddate property, but it is not visible at calendar view. I can see item on "datasheetview" type of view, and if I set the enddate from here it is also visible at calendar view.(strange thing is it is mandatory field)

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:   

my code is as follows

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

}
È stato utile?

Soluzione

Answer was simple update the eventdate and the enddate together. Original solution is can be seen here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top