I have an issue, with this event. What my purpose is: i want to update one of the properties based on few criterias, so i want do fill a field A if field A is empty and the field B is not empty and field C is also not empty.

How to do it properly because with on ItemUpdating some afterproperties are sometimes null or they dont exist at all etc etc ..

Any good advice?

Just to let you know it is about SharePoint 2007

Update: the problem is that i need to compare if the previous value and the new value: so if someone updates an item.

EX: current Item : title=value1; title2= value1

someone updates accordingly: title=newValue

updated item should have following value: title=newValue; title2 = newValue

next time following update: title2=againANewValue;

updated item should be as follwoing: title=againANewValue; title2=againANewValue;

So basically both of the fields should stay synchronised nno matter which one is updated, so I can't know which one of the fields was updated and then which one i should update ..

You see


Just one question: Is there a reason for not using ItemUpdated where all your field would have been updated with the fresh information?

In ItemAdding you must check both BeforeProperties and AfterProperties to be successful in this task.

  • I dont know honestly, is then itemupdated a better solution? Basically I need to check in ItemUpdated for those fields and REupdate the item which i've added or updated? – Shkipper Mar 8 '13 at 12:40
  • Check my post update – Shkipper Mar 8 '13 at 13:09
  • OK so what you need to do is compare the BeforeProperties and AfterProperties of both your field to see if one of the field have been updated and then update the other field accordingly. Other than that it is just basic null check before checking the properties that has to be done i guess. – Robert Lindgren Mar 8 '13 at 14:10
  • On Msdn it says that beforeproperties is applied only to documentlibrary types ... so basically from just a listItem i cannot retrieve them, i tried debugging and it is true, BeforeProperties are always empty :/µ – Shkipper Mar 11 '13 at 7:47

In ItemAdded:

title2 = title

In ItemUpdated workflow:

//Only when there is a change in title/title2 columns
if(title != title2)
    //Meaning title has changed
    if(title.beforeProperties.Value ==  title2)
         title2 = title
    //Meaning title2 has changed
    else if(title2.beforeProperties.Value ==  title)
         title = title2

Basically at the end I solved my issue myself.

Just by checking the listItem.AfterProperties["column"] and comparing them with ListItem["column"] and then setting the again to ListItem.AfterProperties["column"]= value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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