Friday, February 22, 2008

MOSS/SharePoint ItemUpdated() & ItemUpdating Events Not Picking Up Content Type Metadata

This post has moved here: MOSS ItemUpdated() and ItemUpdating Events Not Picking Up Content Type Metadata

4 comments:

VadimK said...

Read your post and thought you might know how to 'intercept' moss page event and prevent moss from stripping/adding html in article content i.e. html comments. If you can point me in general direction of the solution to this problem, I would really appriciate it.

Garth said...

VadimK,
I'm not sure exactly what you are trying to do here. At what point do you want to intercept the page on the "Edit Form" of a list item?
Editing the Existing Edit Forms of SharePoint require you to use SharePoint Designer. You cannot use code in SharePoint designer.

With regards to MOSS Pages they are ASP.Net pages. So if you create your own page using Visual Studio and put it in the 12 hive it will behave as a ASP.Net page so you can use Page_Load or the normal ASP.Net page events.

Biju said...

Hi,



I'm overriding the ItemUpdating event; here I have a field "Start Date”. Now when a user edits the Start date of an item and clicks "OK", I need to capture the previous and latest start date and compare them.



I'm able to getthe previous date by the following code



SPWeb contextWeb = properties.OpenWeb();

SPList spList = contextWeb.Lists[properties.ListId];

SPListItem contextItem = spList.GetItemById(properties.ListItemId);





current_id = Convert.ToInt32(contextItem["ID"]);



if (contextItem["Start Date"] != null)

current_StartDate = (DateTime)contextItem["Start Date"];





But am not able to get the latest(committed) Start date.



I tried using the AfterProperty, but no luck :(





if (properties.AfterProperties["Start Date"] != null)

updated_StartDate = Convert.ToDateTime(properties.AfterProperties["Start Date"].ToString());







Can you help me in finding the solution for the same





PS: I have posted my query on Microsoft’s site also http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/fc56a0f9-9688-479f-b984-5ee3809e72cb/#7259f555-3803-4220-9357-beb4397452d8

Storminator16 said...

I'm sure by now you found the answer to your question, Biju:

http://blogs.msdn.com/varun_malhotra/archive/2009/05/25/modify-a-date-time-value-field-in-event-handlers-through-afterproperties.aspx

That was a great bit of pain for me over the course of a day.