Question

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

Was it helpful?

Solution 3

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;

OTHER TIPS

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.

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
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with sharepoint.stackexchange
scroll top