Questions about Restrict

  • Thread starter Thread starter Dave Townsend
  • Start date Start date
D

Dave Townsend

I am trying to use restrict to find a set of contacts that have at least
one fax number specified and have a setting in a user defined property.
I have phrased my query like this:

[Userprop] = True and ([HomeFaxNumber] <> "" or [BusinessFaxNumber] <>
"" or [OtherFaxNumber] <> "")

Firstly I am assuming that I can use this kind of bracketed notation, I
haven't seen any examples of it anywhere but the restrict seems to succeed.

My problem is that the bit in the brackets doesn't seem to work. How
should I be checking that there is a number in a fax property?

Dave
 
Some of those properties may not exist on the items if they were never
initialized with a value. That's probably why you aren't getting any results
for the fax fields. You might have to initialize those values to a null
string before your restriction. To see if that's the case you can do that on
a group of items and see if your restriction works any better.
 
Ken said:
Some of those properties may not exist on the items if they were never
initialized with a value. That's probably why you aren't getting any
results for the fax fields. You might have to initialize those values to
a null string before your restriction. To see if that's the case you can
do that on a group of items and see if your restriction works any better.

Sorry, I should have made myself clearer. I am getting results for the
fax fields, in fact if I just use the terms in the brackets to try to
find contacts that have a fax number in one of the fax fields the
restrict method returns all the contacts, even though over 2000 of them
do not have fax numbers in any of the fax fields.

Dave
 
Well, I've seen results similar to that when I restricted on properties that
weren't there in all items, Unfortunately you can't really do something like
you can in MAPI or Redemption code where you can set a filter or restriction
on a property existing and having a certain value.

I'd try an experiment of forcing a null string as the value of the fax
fields in every item that doesn't have a value in those fields and then try
the restriction again.
 
Ken said:
Well, I've seen results similar to that when I restricted on properties
that weren't there in all items, Unfortunately you can't really do
something like you can in MAPI or Redemption code where you can set a
filter or restriction on a property existing and having a certain value.

I'd try an experiment of forcing a null string as the value of the fax
fields in every item that doesn't have a value in those fields and then
try the restriction again.

You're right, it appears to be a problem with the fax numbers never
having been assigned anything before. Trouble is, that makes my use of
restrict pointless. The reason for restrict is so I don't have to
retrieve every item to check it matches what I look for. If I have to
retrieve every item to assign a blank string to the fax number then I
may as well just do my tests and ignore restrict.

Microsoft do like to make things easy on us don't they!

Thanks for your help.

Dave
 
If you can use Extended MAPI or are using Redemption to avoid the security
restrictions you can use a MAPI table filter or restriction and that can use
RestrictionExist as a condition for a property and has the added bonus of
running about 5 - 10 orders of magnitude faster than an Outlook restriction
or filter.

Using Redemption I'd create a RestrictionAnd, add a RestrictionExist for
that property to the RestrictionAnd and then add a RestrictionContent for
the value I wanted. For more than one property I'd create a RestrictionOr
and add a set of RestrictionAnd's with the RestrictionExist and
RestrictionContent for each property I wanted to qualify for the
restriction.

If I wanted to get the items from the rows of the resulting filtered
MAPITable I'd include the EntryID of the item in the row and use
NameSpace.GetItemFromID to get items I wanted to change (results of the
MAPITable.Filter are read-only from the table).
 
Back
Top