I'm trying to update SiteUrl
field during ItemAdding event. The field is Type="URL"
. I use this code in Event Receiver, but after user added new item, the field is still empty. (User cannot set this field himself. It has ShowInNewForm="FALSE" ShowInEditForm="FALSE"
).
public override void ItemAdding(SPItemEventProperties properties)
{
SPFieldUrlValue urlValue = new SPFieldUrlValue();
urlValue.Description = "site description...";
urlValue.Url = properties.Web.Url;
properties.AfterProperties["SiteUrl"] = urlValue;
}
Is there some method to save properties, or am I missing something obvious here?
EDIT: turned out, this code is correct, only field name had typo. I found it out only after adding try-catch and debugging inside code.