locked
Are your AfterProperties NULL if item is updated programmatically RRS feed

  • Question

  • Can someone please confirm the following.

    I have an ItemUpdating event and access the AfterProperties collection to validate / force set field values.

    The event works fine when the item is updated via the edit.aspx form.
    But when the item is updated via the API elsewhere (item.Update) the after property returns Null when the event kicks into life.

    Can someone please confirm the behaviour? Please tell me the reason isn't that AfterProperties are only set when using the edit.aspx form. How can they be used for validation otherwise.

    Thanks

    Thursday, January 13, 2011 6:15 PM

Answers

  • It turns out I was missing something obvious. I thought my initial item.update was causing the event to fire but turns out it was within a workflow item.update that was causing it to fire. Then it became obvious. AfterProperties will ONLY contain fields you are actually modifying. By modifying it doesn't mean the value actually has to change. They just need to be in the collection! I knew I was missing something obvious.
    • Marked as answer by Tezler Sunday, January 16, 2011 4:09 PM
    Sunday, January 16, 2011 4:09 PM