1

Server Error in '/' Application.


Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Framework.SharePoint.WebParts.CustomFieldTypes.PreFilledUrlLookupFieldControl.OnLoad(EventArgs e) +1379 System.Web.UI.Control.LoadRecursive() +94
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Control.LoadRecursive() +189
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2951

Could you please let me know where is the error. the code in Visual Studio is as below: enter image description here

When the custom ribbon is clicked, the above code has to be triggered.

It is working in our Development environment, But getting the mentioned error in Integration, Validation and Production environments. Thanks in Advance

2 Answers 2

1

My money is on this line:

PreFilledUrlLookupField field = (PreFilledUrlLookupField)this.Field;

You're passing a null value in a variable here, it seems.

2
  • In Development environment all values are coming properly. In INT environment, value is null somewhere. In INT environment from the above code, when IF condition is succeded ---> we are getting the error. When the If condition is failed, able to open the form but lookup Value is not set. Commented Jul 31, 2019 at 8:32
  • In Development environment, we provided alerts for every step in OnLoad method. We were able to retrieve value of every parameter. But in our Integration environment , The OnLoad method is itself failing. Commented Jul 31, 2019 at 12:13
0

PreFilledUrlLookupFiled field is causing the error. add the null condition check as below for filed. this.field seems to be null.

PreFilledUrlLookupField field = (PreFilledUrlLookupField)this.Field;
    if(field != null){

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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