0

I know that it is possible to write an event receiver to check the constraint but then how can I show a notification / message to the user?

Thanks for sharing your experience and knowledge.

0

You will have to use SPEventPropertiesBase.RedirectUrl and redirect to a different url to show the error. You can then make a custom way to display the error, possibly using a querystring or some other method.

You can't use the JavaScript SP.UI.Notify.addNotification directly but maybe you can make a webpart that picks up custom notifications another way.

  • Thank you. I'm going to give the webpart method a try. it was smart ;) – Reza Oct 3 '12 at 11:53
1

Best option as far as I know

Just create an event receiver for add Item which checks list item every time any item is added and once list items get above limit you can deny user from adding any more items.

However you can look at this question for redirecting in event receiver

  • Thank you. unfortunately i have to only mark one answer :( – Reza Oct 3 '12 at 12:21
  • main focus is to help you and learn, not to get points :P – Mathematics Oct 3 '12 at 13:03
0

I believe if the constrains evaluate to false, you will cancel that event. If that is the case then you can use the below code:

    properties.Cancel = true; 
    properties.Status = SPEventReceiverStatus.CancelWithRedirectUrl; 
    properties.RedirectUrl = "/_layouts/EventReceiverProject1/CustomErrorPage.aspx?Error=" + errorMessage; 

You can find the complete code here

Hope this helps

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.