1

I am working on a team site inside my SharePoint server 2013 on-premise. Now I have two lists:

  1. one list is based on the built-in "Issue Tracking" list template.
  2. the other list is based on the built-in "Custom" list template.

Now I have added two event receivers; one event receiver will fire when item inside a custom list is updating, while the other event receiver will fire when an item inside an issue tracking list is updating. Inside the 2 event receivers I am doing some checks and if the check fails I will return an error to the user, where inside the 2 lists I am using this code inside itemUpdating method:

public override void ItemUpdating(SPItemEventProperties properties)
        {
base.ItemUpdating(properties);
//checking code goes here
if (checkfailed)
  {
    Errormessage = "Approver is not a valid";

    properties.Status = SPEventReceiverStatus.CancelWithError;       

    properties.ErrorMessage = Errormessage;
  }

Now inside the custom list if the check failed, the user will get the following error on the Edit form Approver is not a valid which is what I need, while inside the issue tracking list if the check failed the user will be redirected to this page:

Server Error in '/' Application.

Runtime Error 
  Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed. 

Details: To enable the details of this specific error message to be viewable on the local server machine, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".



<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="RemoteOnly"/>
    </system.web>
</configuration>


Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.



<!-- Web.Config Configuration File -->

<configuration>
    <system.web>
        <customErrors mode="On" defaultRedirect="mycustompage.htm"/>
    </system.web>
</configuration>

enter image description here So can anyone advice on this?

EDIT now i set the CustomError to be off inside the sharepoint web.config file. and i got this error inside the yellow page:-

enter image description here

1

I highly suspect you actually have another (real) error in the code in case the ER runs in the context of the issue tracking list (e.g. a field missing, an internal name misspelled, ...)
First things first: get the actual error message hiding behind "An application error occurred on the server". Check the ULS log to get it, or check this post to enable full error messages in the browser.

  • i do not think there is any other error.. because the check i am doing is to check if the user who is updating the item is inside a group named "Approver" or not..now if the user is inside this group the item will be updated correctly without any error.. but if the user is not inside the "approver" group i need to show this error.. i am doing the same on the other custom list and the error is showing correctly inside the editform... now if i disable the ER on the issue tracking list the item will be updated correctly... so my list is working well...is this correct? – john Gu Jun 19 '17 at 12:52
  • 1
    The one thing to do to be sure you're correct is to get the exact error message (+ stack trace) behind the "yellow page" you see. After that, you'll be sure. You cannot "assume" anything when you debug, especially with sentences like "Im doing the same thing in another context and it works fine there, so the fault is not in my code"... – Evariste Jun 19 '17 at 12:57
  • now i changed the CustomError to be off inside the web.config for my SP application.. and now i will get the actual error "Approver is not a valid" but inside the yellow page , and not inline inside the Edit form.. as follow Server Error in '/' Application.<nativehr>0x81020089</nativehr><nativestack></nativestack>Approver is not a valid .. so this mean i am passing the error correctly is this correct? but the problem is that the error will be shown inside the yellow page and not inline inside the editform!! – john Gu Jun 19 '17 at 13:10
  • can you please check my edit i provided the full error which i got inside the yellow page after i set the customerror to be off.. – john Gu Jun 19 '17 at 13:18
  • any comments from your side on my updates? thanks – john Gu Jun 19 '17 at 13:41

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.