Pregunta

I am trying to copy Calendar items from one list to another list in SharePoint online uisng CSOM. All the fields data copying as excepted but the Recurrence field data appearing as #RENDER FAILED as shown in image. Calendar

Please note that i am trying to copy items from one site collection to another site collection Below is my code:

                    try
                    {
                    itemToCreate["Title"] = SourcelistItem["Title"];
                    itemToCreate["Location"] = SourcelistItem["Location"];
                    itemToCreate["EventDate"] = SourcelistItem.FieldValues["EventDate"];
                    itemToCreate["EndDate"] = SourcelistItem.FieldValues["EndDate"];
                    itemToCreate["fRecurrence"] = SourcelistItem.FieldValues["fRecurrence"];
                    itemToCreate["RecurrenceData"] = SourcelistItem.FieldValues["RecurrenceData"];

                    itemToCreate["TimeZone"] = SourcelistItem.FieldValues["TimeZone"];
                    itemToCreate["XMLTZone"] = SourcelistItem.FieldValues["XMLTZone"];
                    itemToCreate["UID"] = SourcelistItem.FieldValues["UID"];
                    itemToCreate["Duration"]= SourcelistItem.FieldValues["Duration"];
                    }
                    catch (Exception ex)
                    {

                        lbl_Error.Text += ex.Message.ToString();
                    }                       

                itemToCreate.Update();
                destinationContext.Load(itemToCreate);
                destinationContext.ExecuteQuery();

Do i need to include any other columns for copying the Recurrence data

¿Fue útil?

Solución

After including EventType the issue was fixed. The full code is as below

try
{
itemToCreate["Title"] = SourcelistItem["Title"];
itemToCreate["Location"] = SourcelistItem["Location"];
itemToCreate["EventDate"] = SourcelistItem.FieldValues["EventDate"];
itemToCreate["EndDate"] = SourcelistItem.FieldValues["EndDate"];
itemToCreate["fRecurrence"] = SourcelistItem.FieldValues["fRecurrence"];
itemToCreate["RecurrenceData"] = SourcelistItem.FieldValues["RecurrenceData"];    
itemToCreate["TimeZone"] = SourcelistItem.FieldValues["TimeZone"];
itemToCreate["XMLTZone"] = SourcelistItem.FieldValues["XMLTZone"];
itemToCreate["UID"] = SourcelistItem.FieldValues["UID"];
itemToCreate["Duration"]= SourcelistItem.FieldValues["Duration"];
itemToCreate["EventType"]= SourcelistItem.FieldValues["EventType"];
}
catch (Exception ex)
{

lbl_Error.Text += ex.Message.ToString();
}                       

itemToCreate.Update();
destinationContext.Load(itemToCreate);
destinationContext.ExecuteQuery();

Otros consejos

When you copy the "fRecurrence" flag it do only true/false flag. In the form when you check the option it will ask for which day and how many days it occur. System uses that additional information to render as shown in source site screenshot (e.g: Every 1 day(s)).

I am not exactly sure how to copy that additional info but I will update my answer if I can get it.

Licenciado bajo: CC-BY-SA con atribución
scroll top