none
Searching for Contact custom property RRS feed

  • Question

  • Hi All,

    My goal is to search for through all my contacts that have a custom property (a form region property) that is not empty. I tried messing with the ItemProperties restrict method and I seem not to get anything returned.

    I have used the restrict method before when I am searching through all contact items when the property contains a specific email address or name. But now I am trying to search for a specific property that exists and is not empty.

    For example if a have a form region that assigns a property type of dog to a contact  and I want to find all contacts that have the "dog" property and the property is not empty. So the following conditions for contacts could exist.

    1. A contact without the "dog" property.

    2. A contact with the "dog" property and it is empty or blank. (it is a string property)

    3. A contact with the "dog" property  and it is not empty and has a value like "labrador retriever".

    So for the above conditions I am trying to find all contacts that have the "dog" property and the property contains a string containing the doy type.

    I know I can iterate through all the contacts and find the all of the ones that are applicable...but that will cause the CPU to max for sure.

    Also maybe there is a simple way that I am overlooking.

    Any suggestions would be appreciated.

    Thanks,
    Tom

    Monday, March 26, 2012 7:04 PM

Answers

All replies

  • Have you tried to use the SQL syntax (@SQL=) in Items.Find/Restrict use "IS NOT NULL" for that property?


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.2 is now available!

    Monday, March 26, 2012 8:38 PM
  • Okay - how would I search for a property with spaces like "dog breed type"?

    For example...

    (@SQL='dog%20breed%20type IS NOT NULL')

    Monday, March 26, 2012 8:46 PM
  • At the Outlook object model level you'd add a UserProperty and make sure it was added to the folder fields. Then you could filter on that property with NOT IS NULL as a condition. You'd use "@SQL=" preceding your DASL filter for AdvancedFind or folder Items filter.
     
    For example, if you were testing for UserProperty "Dog" your filter would look like this:
     
     
        as a string value, and it would be preceded by "@SQL="

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Thomas Lee3" <=?utf-8?B?VGhvbWFzIExlZTM=?=> wrote in message news:e8ccc53b-d2d0-4223-a303-b0234f4805d9...

    Hi All,

    My goal is to search for through all my contacts that have a custom property (a form region property) that is not empty. I tried messing with the ItemProperties restrict method and I seem not to get anything returned.

    I have used the restrict method before when I am searching through all contact items when the property contains a specific email address or name. But now I am trying to search for a specific property that exists and is not empty.

    For example if a have a form region that assigns a property type of dog to a contact  and I want to find all contacts that have the "dog" property and the property is not empty. So the following conditions for contacts could exist.

    1. A contact without the "dog" property.

    2. A contact with the "dog" property and it is empty or blank. (it is a string property)

    3. A contact with the "dog" property  and it is not empty and has a value like "labrador retriever".

    So for the above conditions I am trying to find all contacts that have the "dog" property and the property contains a string containing the doy type.

    I know I can iterate through all the contacts and find the all of the ones that are applicable...but that will cause the CPU to max for sure.

    Also maybe there is a simple way that I am overlooking.

    Any suggestions would be appreciated.

    Thanks,
    Tom


    Ken Slovak MVP - Outlook
    Monday, March 26, 2012 8:52 PM
    Moderator

  • --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Thomas Lee3" <=?utf-8?B?VGhvbWFzIExlZTM=?=> wrote in message news:f4e9c5ff-b100-4898-a638-8d15efc5af4b...

    Okay - how would I search for a property with spaces like "dog breed type"?

    For example...

    (@SQL='dog%20breed%20type IS NOT NULL')


    Ken Slovak MVP - Outlook
    Monday, March 26, 2012 8:54 PM
    Moderator
  • Perfect ken - that is what I was looking for. Thanks.

    Monday, March 26, 2012 8:56 PM