Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11508

Share Point Calendar RecurrenceData to Simple readable string Edit Recurence.

$
0
0

Hi All,

I am updating recurrence event occurrence using custom Web part.

So now everything is working fine apart from this one Text showing for recurrence Display.

When I Use this line  of code then output is as below.

nItem["RecurrenceData"] = oldItem["RecurrenceData"].ToString();

When I don't set anything for RecurrenceData then its show as below.

<!-- #RENDER FAILED -->

So my question is how can we get the following output.

I'm using this line of code to update Recurrence occurrence event by code.

                                                                            

     public static void UpdateInstanceFromRecurringSeries(SPWeb web, String listname, string recurID)
        {
            string[] splitvals = recurID.Split('.');
            string itemid = splitvals[0];
            SPList calendarList = web.Lists[listname];
            DateTime calendardate = DateTime.Now;
            DateTime eventdate = calendardate;
            DateTime enddate = calendardate;
            if (splitvals[1] == "0")
            {
                calendardate = Convert.ToDateTime(splitvals[2]);
                eventdate = calendardate;
                enddate = calendardate;
            }
            else
                if (splitvals[1] == "1")
                {

                    SPListItem CItem = calendarList.GetItemById(Convert.ToInt32(itemid));

                    eventdate = Convert.ToDateTime(CItem["EventDate"]);
                    enddate = Convert.ToDateTime(CItem["EndDate"]);

                }


            if (calendarList != null)
            {
                // Construct a query that expands recurring events
                SPQuery query = new SPQuery();

                query.ExpandRecurrence = true; //*** important ***
                query.Query = "<Where><DateRangesOverlap><FieldRef Name=\"EventDate\" /><FieldRef Name=\"EndDate\" />" +
                    "<FieldRef Name=\"RecurrenceID\" /><Value Type=\"DateTime\"><Month /></Value></DateRangesOverlap><Eq><FieldRef Name=\"ID\" /><Value Type=\"Integer\">" + itemid + "</Value></Eq></Where>";


                SPListItemCollection calendarItems = calendarList.GetItems(query);

                foreach (SPListItem li in calendarItems)
                {                
                    if (li.RecurrenceID.ToString().Equals(recurID) && (li.ID.ToString().Equals(itemid)))
                      {
                        eventdate = Convert.ToDateTime(li["EventDate"]);
                        enddate = Convert.ToDateTime(li["EndDate"]);


                        web.AllowUnsafeUpdates = true;

                        SPListItem nItem = calendarList.Items.Add();
                        nItem["MasterSeriesItemID"] = li.ID;
                        nItem["UID"] = li["UID"];
                        nItem["EventType"] = 4;
                        nItem["fRecurrence"] = true;
                        nItem["fAllDayEvent"] = Convert.ToBoolean(li["fAllDayEvent"]);
                        nItem["EventDate"] = eventdate.AddHours(1); ;
                        nItem["EndDate"] = enddate.AddHours(1);

                        nItem["RecurrenceID"] = li["RecurrenceID"];
                        nItem["Title"] = "Update:" + Convert.ToString(li["Title"]);

                        nItem["Recurrence"] = li["Recurrence"];
                        nItem["TimeZone"] = li["TimeZone"];
                        nItem["Duration"] = (enddate.TimeOfDay - eventdate.TimeOfDay).TotalSeconds;
                        nItem.Update();


                        calendarList.Update();
                        web.AllowUnsafeUpdates = false;

                        break;
                    }

                }
            }



        }

I want answer for how i can get readable string from xml via code or any sharepoint provision.


Viewing all articles
Browse latest Browse all 11508


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>