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
JJoshJLJJoshJL 

Or Statement

What is the easiest way to use or statments in your query. What I currently have does not seem to want to work right and returns a malformed query. Thanks in advance.

zipfind1 = "BillingPostalCode = '" & zip & "'"

soql1 = "and type != '" & typec & "' or type != '" & typem & "'"

soql2 = "select id from account where " & zipfind1 & soql1

 

Dim qr As salesforce.QueryResult = Nothing

binding.QueryOptionsValue = New salesforce.QueryOptions

qr = binding.query(soql2)

c = 0

If qr.size > 0 Then

Console.WriteLine("blah")

For c = 0 To qr.records.GetUpperBound(0)

Dim m As salesforce.Account = CType(qr.records(c), salesforce.Account)

id = m.Id

 

API 4.0

VB.net 2003

 

Thanks again

Josh

Next

End If

SuperfellSuperfell
As indicated in the docs you need to add ( ) to determine the ordering between the or's and and's, i'd guess you want this
soql1 = "and ( type != '" & typec & "' or type != '" & typem & "' )"
instead of
soql1 = "and type != '" & typec & "' or type != '" & typem & "'"
darozdaroz


JJoshJL wrote:

zipfind1 = "BillingPostalCode = '" & zip & "'"

soql1 = "and type != '" & typec & "' or type != '" & typem & "'"

soql2 = "select id from account where " & zipfind1 & soql1


If I'm reading this right the concatinated string will look like this:

select id from account where BillingPostalCode = 'zip'and type

I believe there has to be a space after that closing tick around the zipcode before the and keyword in order for the query to run.

JJoshJLJJoshJL
that did it... thanks