Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
See why IDC MarketScape names Qlik a 2025 Leader! Read more
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Salesforce SOQL not returning correct value

Hi,
Can anyone explain me why this select:
"SELECT Id, Unit_Price__c, CreatedById, CreatedDate, Deal_Type__c FROM Equipment_Data__c"
Returns a null value "Unit_Price__c" while
"SELECT Id, Unit_Price__c, CreatedById, CreatedDate FROM Equipment_Data__c"
Returns a correct value...
I'm really puzzled with this!? So any help is appriciated.. 0683p000009MACn.png
Thanks in advance.
Labels (2)
4 Replies
Anonymous
Not applicable
Author

Just to clarify further, this is SOQL Select from SalesForce.com...
If I do:
"SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c", I will get the correct Deal_Type__c, but no value for Unit_Price.
If I do:
"SELECT Unit_Price__c FROM Equipment_Data__c", I will get the correct Unit_Price__c
Unit_Price__c is a "Number(16,2)" field and Deal_Type__c is a "Picklist" field....
Any ideas?
Anonymous
Not applicable
Author

you have to change your query to get the value of the picklist for SOQL. use
SELECT Unit_Price__c, toLabel(Deal_Type__c) FROM Equipment_Data__c
Anonymous
Not applicable
Author

It unfortunately doesn't work. For info I that both of the below return correct values:
"SELECT Deal_Type__c FROM Equipment_Data__c" (without toLabel) and the
"SELECT Unit_Price__c FROM Equipment_Data__c"
But when I combine them as:
"SELECT Unit_Price__c, Deal_Type__c FROM Equipment_Data__c" or even "SELECT Unit_Price__c, toLabel(Deal_Type__c) FROM Equipment_Data__c" I only get the Deal_Type__c value - not the Unit_Price__c
Anonymous
Not applicable
Author

This is my code, if it help anyone to help me 0683p000009MACn.png
Private Sub btnRtvOutlook_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRtvOutlook.Click
' *** Delete all records in databse, which has been uploaded today
Dim myConnection As New System.Data.SqlClient.SqlConnection(myConnString)
Dim myQuery As String = "DELETE FROM tblXIST_ESR_OPP WHERE DATEDIFF(day, UPLOAD_TIME, GETDATE()) = 0"
Dim myCommand As New System.Data.SqlClient.SqlCommand(myQuery, myConnection)
myCommand.Connection = myConnection
myCommand.Connection.Open()
myCommand.ExecuteScalar()
myCommand.Parameters.Clear()
myCommand.Connection.Close()
myConnection.Close()
' *** INSERT TODAYS OUTLOOK INFORMATION INTO THE DATABASE
Dim qs As String
'This one works perfectly at returns the Unit_Revenue__c result being "26000"
'qs = "SELECT Id, Unit_Revenue__c FROM Equipment_Data__c"
'This one also works and returns the deal type perfectly being "Cash"
'qs = "SELECT Id, Deal_Type__c FROM Equipment_Data__c"
'This one also works, and return both field being "26000 - Cash"
'qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c FROM Equipment_Data__c"
'This one doesn't work, it only returns "- - 14-06-2012 11:09:59"
qs = "SELECT Id, Unit_Revenue__c, Deal_Type__c, CreatedDate FROM Equipment_Data__c"
Dim qr As apex.QueryResult = binding.query(qs)
If (qr.size = 0) Then
Else
For i As Integer = 1 To qr.records.GetUpperBound(0)
Dim equipment As apex.Equipment_Data__c = CType(qr.records(i), apex.Equipment_Data__c)

'*** HERE I NORMALLY HAVE A FUNCTION THAT RETURNS THE VALUES INTO A SQL DATABASE, BUT
'*** I HAVE CUT IT OUT TO REDUCE PLACES OF ERRORS AND ARE ONLY RETURNING VALUES IN MSGBOX
MsgBox(equipment.Unit_Revenue__c & " - " & equipment.Deal_Type__c & " - " & equipment.CreatedDate)

Next
End If
End Sub