开发者

Get self defined AfterProperties column in Event Receiver

开发者 https://www.devze.com 2023-03-21 13:41 出处:网络
i want to show an error 开发者_C百科message, whenever the user adds an item. So i use code similar to that:

i want to show an error 开发者_C百科message, whenever the user adds an item. So i use code similar to that:

public override void ItemAdding(SPItemEventProperties properties)
{
 properties.Cancel = true;
 properties.ErroMessage = properties.AfterProperties[columnname];
}

Unfortunately it only work, when the columname ist an default column. For self defined columns it doesn't work. I get this error message:

event receiver has canceled the request

I tried everything: The columnname is right, the column is not null,.. If i write a console application getting this columns, everything will work well. Only in the event receiver it doesn't work.

Can anybody help? Would be great!


hopefully not too stupid a question but are you using a column name that SharePoint recognizes? The reason I ask is that you mention that these are self defined columns. When you define a column via the UI, the column name behind the scenes ends up as something similar but not the same.

This page gives you a bit of an over view of DisplayName vs InternalName. And as the author mentions, things get even more complicated when you rename a column via the UI.

0

精彩评论

暂无评论...
验证码 换一张
取 消