Solution:
In general case, Check out is required for updating property. If you use "Checking in" event for this then you will get error
"
Save Conflict: Your changes conflict with those made concurrently by another user. If you want your changes to be applied, click Back in your Web browser, refresh the page, and resubmit your changes."
So use following code:
public override void ItemCheckedIn(SPItemEventProperties properties)
{
base.ItemCheckedIn(properties); //Set NewColumn value = Other Column + ID
using (SPWeb mySite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
{
try{
mySite.AllowUnsafeUpdates =true;
SPFile file = properties.ListItem.File;
file.Update();
properties.ListItem["NewColumn"] =properties.ListItem["OtherColumn"].ToString()+ properties.ListItem["ID"].ToString();
properties.ListItem.SystemUpdate();
}
catch (Exception ex){
mySite.Description = ex.ToString();
}
mySite.Update();
}
}
Um excuse my ignorance...im new to sharepoint as ive been lumped with it from its predecessor. Where do I put this code??
ReplyDeleteHi Belle,
ReplyDeleteSee following URL:
http://urenjoy.blogspot.com/2008/10/how-to-handle-event-using-net-in-moss.html