Searching through Items with created Property (DisplayFormat = FALSE)

R

Ryan Hubbard

I was wondering if there was a way of searching through a collection
of items with a userproperty that was added with the DisplayFormat set
to False. I know how to search if the Display format is set to True
therefor registering the field in the User Defined fields but I can't
seem to find a method for when it is not. Thanks
 
K

Ken Slovak - [MVP - Outlook]

Search how? You should be able to iterate the collection and check for the
value of any UserProperty on each item. Show the code you're trying to use.

As far as I know False is not a valid setting for DisplayFormat. The valid
settings are those for the OlUserPropertyType enum and the olYesNo value (6)
is usually used for True/False fields.

You can't use a filter or restriction on a user property unless it was added
to the fields in the folder, and often user properties won't actually exist
in an item unless the property was initialized to a value.
 
R

Ryan Hubbard

Hey Ken,
I believe you answered my question. What I was doing was adding a
user property but using the DisplayFormat = false. All that does is not
add it to the list of "User Defined Fields in Folder" but the property
still exists.

example:
UserProperties.add <NAME>, <TYPE>, <ADDTOFOLDERS>, <DISPLAYFORMAT>

objTask.UserProperties.Add "test", olText, ,False

I was wondering if there was some type of restrict or find that would
search these type of fields. I know I can enumerate throught them but
potentially there could be a couple thousand items so I know using vba
to do that I will run into performance issues. I was hoping there was a
faster way already implemented.

Thanks ken for the reply,
Ryan


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
K

Ken Slovak - [MVP - Outlook]

You cannot use Restrict or Find unless the field has been added to the
folder fields, and even if it has it might not have been initialized to a
value in which case it might not actually exist in a specific item. That's
how MAPI handles user properties, it doesn't actually create them in an item
until they have a value. So when I add a field that I might want to restrict
on I always initialize it to a default value.

False is not a valid value for DisplayFormat. What you are doing by using
False is implicitly using the value of False being 0 in VB/VBA. However,
that may not be correct in another language, so it's bad programming
practice. It's also not listed as a valid setting for the DisplayFormat
argument. Look in the Object Browser for UserProperties.Add and see what the
valid values are for the arguments of that method.

AddToFolders is the argument that controls whether it's added to the folder,
the DisplayFormat argument is used to set how the field is displayed in the
UI.

I would add the field to the folder and initialize it to a default value
when it's added. That way it can be used in a restriction.

Your posting interface doesn't include any of the preceding thread. Please
do so manually so the thread can be followed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top