Item update has repeatability in SharePoint

I had a list of events. I created a new element that repeats daily (Start Time: 1/5/2010 12:00 AM and End Time: 5/30/2010 12:00 AM). I want to remove an item that has a start time: 12/05/2010 12:00, but my application has thrown an exception.

My code is as below:

   DateTime eventDate = DateTime.Parse(list.Fields.GetFieldByInternalName("EventDate").GetFieldValueAsHtml(DateTime.Parse(this.DateTimeOfItem).ToUniversalTime()));
                            SPQuery pQuery = new SPQuery();
                            pQuery.ExpandRecurrence = true;
                            pQuery.CalendarDate = eventDate.AddDays(-1);
                            pQuery.Query = string.Format("<OrderBy><FieldRef Name=\"EventDate\"/></OrderBy><Where><And><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" /><FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Week /></Value></DateRangesOverlap><Eq><FieldRef Name=\"ID\" /><Value Type=\"Counter\">{0}</Value></Eq></And></Where>", this.ID);
                            SPListItemCollection itemColl = list.GetItems(pQuery);
                            int index = 0;
                            while (index < itemColl.Count)
                            {
                                SPListItem item = itemColl[index];
                                if (DateTime.Parse(item["EventDate"].ToString()).CompareTo(eventDate) == 0)
                                {
                                    web.AllowUnsafeUpdates = true;
                                    item["UID"] = Guid.NewGuid().ToString();
                                    item["EventType"] = 3;
                                    item["RecurrenceID"] = eventDate;
                                    item["MasterSeriesItemID"] = this.ID;
                                    item["XMLTZone"] = null;
                                    item["RecurrenceData"] = "Every 1 day(s)";
                                    item.Update();
                                    list.Update();
                                    web.AllowUnsafeUpdates = false;
                                    break;
                                }
                                index++;
                            }

I do not know why I cannot update this item. Please help me.

thank

PD.

+3
source share
2 answers

To remove an instance of a recurring event in SharePoint, you must actually add the NEW record and mark it as deleted.

SharePoint , ( ), , . CAML "" , .

1 . " " RecurrenceDate.

(, "1/5/2010 12: 00 AM" ), .

, :

  • MasterSeriesItemID -
  • EventType - 3 , 4
  • RecurrenceID - ,

.

SharePoint iCal

, SharePoint 2007 , / UTC RecurranceID, " " ( , )

+13

Source: https://habr.com/ru/post/1744954/


All Articles