function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Again AgainAgain Again 

Problem with error trapping with Salesforce API Error object

Hi everyone,

     We recently have updated our Enterprise WSDL to expose a newly added field from the SalesForce GUI. Once we updated the WSDL on a ASP.Net 2.0 application.We cannot use the following pattern to trap errors anymore.

 

Code:

  Binding is defined in the partial class declaration of the page as the following:
 
Private binding As sforce.SforceService

and is later referenced in the following code in a function:


                Dim SaveResult() As sforce.SaveResult
                If hdContactID.Value <> "" Then
                    Try
                        If binding Is Nothing Then
                            Response.Write("Binding nothing")
                        Else
                            Response.Write("Binding something: " & binding.Timeout.ToString)
                        End If
                        If contactrecords Is Nothing Then
                            Response.Write("contactrecords nothing")
                        Else
                            Response.Write("<LI>" & contactrecords(0).Id)
                        End If
                        SaveResult = binding.update(contactrecords)
                    Catch ex2 As Exception
                        SqlHelper.ExecuteNonQuery(ConfigurationManager.AppSettings("connStrErrorLog"), "SF_WebAppLogsInsert", "Binding - update", ex2.Message.ToString, "EditContact.vb", "Binding.update", "", "", "Update Contact", -1)
                        Response.Write("<font color=green><LI>Error!: " & ex2.ToString)
                        Exit Sub
                    End Try

                    Dim upderr As sforce.Error 
                    If Not SaveResult Is Nothing Then
                        upderr = SaveResult(0).errors(0)
                    Else
                        Exit Sub
                    End If


 
The ASP.Net 2.0 error is occuring at upderr = SaveResult(0).errors(0) with an 'Object reference not set to an instance of an object' error.

We have used this exact same code without issue before the change to the most recent Enterprise WSDL change.

Does anyone have an idea as to why this error is occuring now?

 

Thanks!

 

 

Again AgainAgain Again
Sorry for the triple post... Still getting used to this all.
DevAngelDevAngel
You should always be checking if saveResult(0).success == true, and it not, then go grab the error.