SharePoint Developer Center >
SharePoint Products and Technologies Forums
>
SharePoint - Development and Programming
>
AfterProperty in ItemUpdating event
AfterProperty in ItemUpdating event
Hi,
I override ItemAdding/ItemUpdating/ItemDeleteing events of list item. When I am updating a listitem from EditForm, AfterProperty on ItemUpdating event is return null instead of new changed values. I checked the field name, its field internal name. Same happened with BeforeProperty. I didn't know the reason why both are returing null????
Some article giving clue about how this, but I am not able to conclude any thing.
http://msdn.microsoft.com/en-us/library/ms463479.aspx
Answers
- Hi,
Thanks for reply.
I am using field's internal name. But its not the problem.
I got the reason of AfterProperty is null. Actually I have some hidden fields (not display on any of the form) in sharepoint list and AfterProperty will return values for the visible fields only. All other fields values are always null even we provide the field's internal name.
And I am using "property.AfterProperty", I have typing mistake in my previous reply and sorry for that.- Marked As Answer byAni Michal Saturday, November 07, 2009 5:30 AM
All Replies
- HiCould you post your event handler code. The AfterProperties should contain the changed value and the properties.listitem should contain the original value in the itemupdating event. BeforeProperties will have no value.
- I created a custom list using object model and implement a class inherited from SPItemEventReceiver. My ItemReceiver class code is as follow:
Here col1 is of type GUID and it always contains EmptyGuid and Control will move to else condition having return statement. I also check the same thing with title and other fields. same thing is happened.public override void ItemUpdating(SPItemEventProperties properties) { try { base.ItemUpdating(properties); if (listItemProperties.AfterProperties[list.Fields["Col1"].InternalName] != null ) { //Some business logic are here } else { return; } } catch (Exception ex) { properties.ErrorMessage = ex.Message; properties.Cancel = true; } }
- Hi
I suspect your field name is wrong - list.Fields["Col1"].InternalName is not returning the value you are expecting. To test, rather hard code the field name i.e. properties.AfterProperties["name_of_field"]. Verify the fieldname is correct in the "Name" attribute in the field element in your schema.xml (use something like vsewss to generate the list definition).
Also, why are you using listItemProperties.After.... rather than the properties.After.. , passed in as a parameter to the eventhandler? - Hi,
Thanks for reply.
I am using field's internal name. But its not the problem.
I got the reason of AfterProperty is null. Actually I have some hidden fields (not display on any of the form) in sharepoint list and AfterProperty will return values for the visible fields only. All other fields values are always null even we provide the field's internal name.
And I am using "property.AfterProperty", I have typing mistake in my previous reply and sorry for that.- Marked As Answer byAni Michal Saturday, November 07, 2009 5:30 AM


