Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

No matter what I do, before and after for title are always null. This is an item updated receiver in the meetings or event list

![public override void ItemUpdated(SPItemEventProperties properties)
        {
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "BEGIN");
            base.ItemUpdated(properties);
            try
            {
                base.EventFiringEnabled = false;
                SPSite site = properties.Web.Site;
                string sitename= properties.BeforeProperties\["Title"\].ToString();
                SPWeb web = site.RootWeb.Webs\[sitename\];
                web.AllowUnsafeUpdates = true;
                string prefix = properties.BeforeProperties\["Title"\].ToString().Substring(0, 2);
                web.Title = properties.AfterProperties\["Title"\].ToString();
                DateTime eventDate = properties.AfterProperties.GetValueAsDateTime(MeetingsCommon.Constants.FIELDS_EVENTDATE_NAME);
                if (eventDate != DateTime.MinValue)
                {
                    string titleMeetingCalendarItem = eventDate.ToString("yyyyMMdd");
                    titleMeetingCalendarItem = string.Format("{0}{1}", prefix, titleMeetingCalendarItem);
                    properties.AfterProperties.SetAfterPropertyValue("Title", titleMeetingCalendarItem);
                    web.ServerRelativeUrl = "/" + titleMeetingCalendarItem;               
                }
                web.Update();

                web.AllowUnsafeUpdates = false;
                base.EventFiringEnabled = true;
            }
            catch (Exception ex)
            {
                Logger.LogError("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", ex);
                properties.ErrorMessage = ex.Message;
                properties.Cancel = true;
            }
            finally
            {
                base.EventFiringEnabled = true;
            }
            Logger.LogDebug("MeetingCalendarEvents", "ItemUpdated(SPItemEventProperties properties)", "END");
        }][1]
share|improve this question

1 Answer 1

up vote 1 down vote accepted

You should try to use the ItemUpdating instead of the itemupdated event. In the itemupdated event, there aren't any before and after properties! Only while updatING...

share|improve this answer
    
I dont think thats correct. synergyonline.com/Blog/Lists/Posts/Post.aspx?ID=122 –  L.V. Sharepoint Architect Aug 2 '12 at 14:54
    
but yes, I suppose I can use the item updating event. –  L.V. Sharepoint Architect Aug 2 '12 at 14:55
    
the code doesnt work either on item updating event., beforeproperties["Title"] is always null –  L.V. Sharepoint Architect Aug 2 '12 at 15:06
    
If you look at the blog post you linked to, it says that beforeproperties is always NULL in a list, use properties.ListItem instead. –  Anders Aune Aug 2 '12 at 18:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.