1
我有一個包含多列的自定義列表。驗證由自定義內容類型進行。現在我想要兩列的組合是唯一的。直到我知道我沒有找到一種方法來解決這個問題,所以我的想法是使用eventreceiver或customcontenttype。Sharepoint多列驗證
我試了一下:
ListEventReceiver
public override void ItemAdding(SPItemEventProperties properties)
{
if (properties.AfterProperties["a1"].ToString() == properties.AfterProperties["a2"].ToString())
{
properties.Status = SPEventReceiverStatus.CancelWithError;
properties.Cancel = true;
properties.ErrorMessage = "Failure";
}
base.ItemAdding(properties);
}
它工作正常,但錯誤信息未顯示爲驗證錯誤。這是一個新的錯誤頁面。
CustomContenttype
如果我嘗試在一個自定義的驗證CONTENTTYPE我不能從contentType中訪問其他字段的值。所以我無法比較兩個字段或檢查他們是獨特的。
謝謝,但我在尋找ValidationErrors,因爲這個錯誤會刪除表單中的所有內容,並且用戶必須重新輸入數據。 – HW90