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
AhlomonAhlomon 

Error on red line "Object reference not set to an instance of an object"

I am getting error on red line "Object reference not set to an instance of an object" that doesn't makes sence for me. I know that the value is empty for gto_data.LB_Perf__c.ToString

Please help

=========================================================================

Private Function GetGTO() As Boolean

Dim qr As sforce.QueryResult

Dim queryString As String

queryString = "Select Id,Name,CreatedDate,CreatedById,Test_Type__c,Trl_Run_By__c,Dte_Run__c,Time_Spent_On_GTO__c, LB_Perf__c,Business_Status__c,Business_Status_Reason__c,Dte_Clsd__c,LB_PdNm__c from ISGTO__c"

Try

qr = binding.query(queryString)

If Not qr.records Is Nothing Then

Dim i As Integer

For i = 0 To qr.records.Length - 1

Dim gto_data As sforce.ISGTO__c

gto_data = qr.records(i)

GTO_ID_arr.Add(gto_data.Id.ToString)

GTO_NAME_arr.Add(gto_data.Name.ToString)

GTO_CREATION_DATE_arr.Add(gto_data.CreatedDate.ToString)

GTO_CREATED_BY_ID_arr.Add(gto_data.CreatedById.ToString)

TRIAL_TYPE_arr.Add(gto_data.Test_Type__c.ToString)

TRIAL_RUN_BY_arr.Add(gto_data.Trl_Run_By__c.ToString)

TRIAL_RUN_DATE_arr.Add(gto_data.Dte_Run__c.ToString)

TIME_SPENT_arr.Add(gto_data.Time_Spent_On_GTO__c.ToString)

BLADE_PERFORMANCE_arr.Add(gto_data.LB_Perf__c.ToString)

BUSINESS_STATUS_arr.Add(gto_data.Business_Status__c.ToString)

BUSINESS_STATUS_REASON_arr.Add(gto_data.Business_Status_Reason__c.ToString)

TRIAL_DATE_CLOSED_arr.Add(gto_data.Dte_Clsd__c.ToString)

TRIAL_BLADE_PRODUCT_arr.Add(gto_data.LB_PdNm__c.ToString)

Next

Else

GetGTO = False

End If

Return GetGTO

Catch ex As Exception

Console.WriteLine(ex.Message & ex.StackTrace)

Finally

End Try

End Function

werewolfwerewolf
It's telling you that either BLADE_PERFORMANCE_arr is null, or gto_data.LB_Perf__c is null.  If you know that LB_Perf__c is null, then why are you calling ToString on it?  You can't call methods on a null object.

BTW I think you've posted this on the wrong board.  You probably want the .NET board.
AhlomonAhlomon

so, then how I can check if it's null or not? I need the syntax.

Thanks.

 

werewolfwerewolf
Well either debug it and look at the variable values in there, or put an if(variable == null) around the block.
werewolfwerewolf
Or if(variable!=null) anyway.