Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I need to show an errormessage in a popup or redirecting to another page when an error occurs in the ItemAdded (not ItemAdding...) eventreceiver. Anyone knows how to do this?

I've tried:

 private void ShowErrorMessage(SPItemEventProperties properties, string message)
    {
        properties.Status = SPEventReceiverStatus.CancelWithError;
        properties.ErrorMessage = message;
        properties.Cancel = true;
    }

And set web.config values to CallStack="false" & customError="On". But I guess this only works for ItemAdding event?

Any other solutions for my problem?

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

You can't show a message from ItemXXXed and you can't cancel either. If you need that then you should implement ItemXXXing.

You can't cancel because the changes has already been made and you can't show a message because the UI isn't waiting for you (unless you specify synchronous, but still I don't expect SharePoint to look at Status)

share|improve this answer
    
I'm using the ItemUpdated because when I approve or reject a listitem, the workflow should start, which isn't the case if I use the ItemUpdating event (or am I wrong?) –  Ruben Herman May 24 '12 at 11:05
1  
The main difference between ItemUpdated and ItemUpdating is where the information is and what you can do. In ItemUpdating all the changes are only in properties bacuse the DB isn't changed and you can stop the change from happening. In ItemUpdated the change has been put into the DB (and listitem) and you can't stop the change. Unless cancelled they will always occur in pairs. –  Per Jakobsen May 24 '12 at 11:12
    
So there isn't any way to show a message to the user after he approves or rejects the listitem? –  Ruben Herman May 24 '12 at 12:21
    
Not using event receivers in a nice way. A HACK could be to check in ItemUpdating if what's going on is a appove/reject, then perform the operation while Disabling events and CancelWithError, but that's definitly a hack and will confuse any program trying to Approve/Reject) –  Per Jakobsen May 24 '12 at 13:19
    
Why would you want to show the error message AFTER he approves/rejects the item? –  Kit Menke May 24 '12 at 13:24
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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