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
Brian.ax17Brian.ax17 

NOT Operator sample

Is there a Query sample which includes construction of the "NOT" operation?

I'm trying to construct a filter something like: firstName starts with "abc" and NOT lastName contains "xyz"

My attempts so far result in "value of filter criterion for not must be of type struct".

domdom

Brian,

It sounds to me like your "value" is not a structure when specifying the operator "not".

Note: When you are setting up and "and" or "or" filter the "value" needs to be an array of filters but with the "not" operator it needs to be a structure.

Here's the pseudo code for it

(operator"and" value

array((field"firstname"    operator"starts with" value"abc") ,

(operator"not" value (field"lastName" operator"starts with" value"xyz") ))

Here is the raw XML-RPC message..

<?xml version="1.0" encoding="utf-8" ?>

<methodCall><methodName>sfdc.query</methodName><params><param><value><struct><member><name>select</name><value><array><data><value><string>id</string></value><value><string>ownerID</string></value><value><string>createdDate</string></value><value><string>createdByID</string></value><value><string>lastModifiedDate</string></value><value><string>lastModifiedByID</string></value><value><string>firstName</string></value><value><string>lastName</string></value><value><string>systemModstamp</string></value></data></array></value></member><member><name>version</name><value><string>1.9</string></value></member><member><name>client</name><value><string>VisualSmart/1.0</string></value></member><member><name>type</name><value><string>contact</string></value></member><member><name>filter</name><value><array><data><value><struct><member><name>operator</name><value><string>and</string></value></member><member><name>value</name><value><array><data><value><struct><member><name>field</name><value><string>firstName</string></value></member><member><name>operator</name><value><string>startsfwith</string></value></member><member><name>value</name><value><string>abc</string></value></member></struct></value><value><struct><member><name>operator</name><value><string>not</string></value></member><member><name>value</name><value><struct><member><name>field</name><value><string>lastName</string></value></member><member><name>operator</name><value><string>startsfwith</string></value></member><member><name>value</name><value><string>xyz</string></value></member></struct></value></member></struct></value></data></array></value></member></struct></value></data></array></value></member></struct></value></param></params></methodCall>

Hope this helps,

Dom

 

 

domdom

It seems like an extranious "f" was inserted when I pasted the raw packet..

The two "startsfwith"s need to be "starts with" obviously..

Dom

Barry LBarry L

Here you go.  I just copied the filter.

You might want to take a look at the tool I posted in the General group.  I generated this in about 10 seconds

<member>
 <name>filter</name>
 <value>
  <array>
   <value>
    <struct>
     <member>
      <name>operator</name>
      <value>and</value>
     </member>
     <member>
      <name>value</name>
      <value>
       <array>
        <value>
         <struct>
          <member>
           <name>operator</name>
           <value>starts with</value>
          </member>
          <member>
           <name>field</name>
           <value>firstName</value>
          </member>
          <member>
           <name>value</name>
           <value>abc</value>
          </member>
         </struct>
        </value>
        <value>
         <struct>
          <member>
           <name>operator</name>
           <value>not</value>
          </member>
          <member>
           <name>value</name>
           <value>
            <struct>
             <member>
              <name>operator</name>
              <value>contains</value>
             </member>
             <member>
              <name>field</name>
              <value>lastName</value>
             </member>
             <member>
              <name>value</name>
              <value>xyz</value>
             </member>
            </struct>
           </value>
          </member>
         </struct>
        </value>
       </array>
      </value>
     </member>
    </struct>
   </value>
  </array>
 </value>
</member>

Brian.ax17Brian.ax17
Being fairly new to all this, I was hoping to find a bit of VB.NET or C# code to copy.
Brian.ax17Brian.ax17

This is the code I am trying to develop:

Dim filter(0) As Object 'Final filter array
Dim andFilter1(1) As Object '
Dim andFilter2(0) As Object '

'Create simple filter
andFilter1(0) = MakeSimpleFilter("cf_00N30000000bqfI", "UK CID", "starts with")
andFilter2(0) = MakeSimpleFilter("lastName", "Datawarehouse", "contains")
andFilter1(1) = MakeAndOrFilter(andFilter2, "not")
filter(0) = MakeAndOrFilter(andFilter1, "and")

(The functions MakeSimpleFilter and MakeAndOrFilter are unchanged from the online samples.)

I don't understand how to create a "struct" element for the "not" operation. Can anyone show me how?

Thanks, Brian

Brian.ax17Brian.ax17

OK. Spotted my mistake.  

andFilter2 shouldn't have been an "array".

 

GaganGagan

hi Brian,

im using api version 2.0 and vs.net 2003 for creating this application(vb.net and asp.net). i am facing the same problem for accessing the records using multiple query filters.
if your code is working fine please send me the code for creation of multiple filters. i will appriciate if u can do so.
Thanx and regards.


Gagan

gagan.bandhu@theikos.com

Brian.ax17Brian.ax17

Here is my code, it uses functions from the original samples:

Dim filter(0) As Object 'Final filter array

Dim andFilter1(1) As Object '

Dim andFilter2 As Object '

'Create simple filter

andFilter1(0) = MakeSimpleFilter("cf_00N30000000bqfIEAQ", "UK CID", "starts with")

andFilter2 = MakeSimpleFilter("lastName", "Datawarehouse", "contains")

andFilter1(1) = MakeAndOrFilter(andFilter2, "not")

filter(0) = MakeAndOrFilter(andFilter1, "and")

My original mistake was to define andFilter2 as an array.
Hope this helps,

Brian

GaganGagan

hi Brian,
Great thanx for the help,
Here is the problem,,
I have original function "makesimplefilter" but not the other one...."MakeAndOrFilter"

How can i get "MakeAndOrFilter" or u can send me this......

my email address is devilindel@yahoo.com ,  i m also online on that via yahoo msngr.

Please reply....

Thanks and regards.
Gagan