Redemption Auto-complete

G

Guest

Hi,

Could anyone please point me to an example of using Redemption to create a custom Auto-complete function. I have a Public Folder full of Company Contact Items. I have another Public Folder full of Contacts. I want to be able to start typing a company name into a text box bound to the Company field and have it return possibilities based on the items in the company folder.

I've tried several of the Restriction methods in Redemption, but the FL_SUBSTRING simply returns the first item that has the partial search string anywhere in the name not the first letters in the name. I tried FL_PREFIX which returns not items at all and of coarse FL_FULLSTRING isn't what I'm looking for either. Does someone have an example of how to do this?

Thanks,

John
 
K

Ken Slovak - [MVP - Outlook]

Have you tried it using the contacts as AddressEntry items in an
AddressEntries collection? There's a sample on the Redemption Web site that
does that, it's at
http://www.dimastr.com/redemption/mapitable.htm#resaddressbook




John Riddle said:
Hi,

Could anyone please point me to an example of using Redemption to create a
custom Auto-complete function. I have a Public Folder full of Company
Contact Items. I have another Public Folder full of Contacts. I want to be
able to start typing a company name into a text box bound to the Company
field and have it return possibilities based on the items in the company
folder.
I've tried several of the Restriction methods in Redemption, but the
FL_SUBSTRING simply returns the first item that has the partial search
string anywhere in the name not the first letters in the name. I tried
FL_PREFIX which returns not items at all and of coarse FL_FULLSTRING isn't
what I'm looking for either. Does someone have an example of how to do this?
 
K

Ken Slovak - [MVP - Outlook]

Exchange does cache restrictions for up to 8 days by default and depending
on how many users you have and how many restrictions are cached, it can
cause a load on an Exchange server. The perceived result also depends on
processor speed, how many spindles are holding the Exchange databases,
server memory, how many processors the server has and if clustered servers
are used. So it's impossible to say what the effects will be offhand.

You can try using Find, FindNext rather than a restriction, but I use
restrictions for some of my addins and I haven't had any real problems
reported because of that. Your mileage may vary. Of course an alternative is
to change the setting for how long restrictions are cached :)




John Riddle said:
Ken,

Thanks. I'm trying that now. One question though, I normally don't like
doing restrictions. I try to do the Find, FindNext method due to Exchange's
wanting to cache restrictions. Will this method cause poor performance on
the Exchange server?
 
K

Ken Slovak - [MVP - Outlook]

The only thing I can say about the perf issues are to see what happens in
usage. Or you can simulate a load of many users on a test server if you have
one.

A wild guess here, but what is the contents of Row(1)? Is it an error
string? I usually check for things like that if the field can possibly be
created in the item as a MAPI property if it has been initialized.

I don't follow what you are saying about the company name with (Email) after
it and what you actually have in the CompanyName Outlook property. One thing
I do know is that Outlook won't resolve a name unless it has a valid
electronic address, which can be an email address or a fax number. I bet the
restriction is doing the same thing on a MAPI level, but Dmitry would know
if that's true.




John Riddle said:
Ken,

Thanks for all your help. Actually, I have already set my view cache to 8
hours because we do a lot of folder restrictions and we only have a 2.4Ghz
server with 1mb of RAM running Small Business Server 2003. I've set the 3GB
switch as well and everything seems to hum along great.
However, if people are constantly creating new contacts (which they do
sometimes a hundred a day) and filling in the company field with the
auto-complete function that I'm trying to create, I was wondering if this
restriction will be cached and re-used for each contact or if a new
restriction would be created each time a user types in company info.
I've gotten the method that you described to work as long as the the
Company Item has a Fax # or an Email Address (a few have Faxes, but none
have Email Addresses because they are custom item created to hold company
info, not personal info). For most, it does not resolve a name because there
is no email or fax. Even though, all items do have a PR_DISPLAY_NAME
property that I want to use. Also, the field is populated with "Company Name
(Business Fax)", instead of just plain "Company Name". Here is my code
behind an Outlook Contact Item:
RES_PROPERTY = 4
RELOP_EQ = 4

Sub Item_PropertyChange(ByVal PropName)
dim Columns(1)
dim Row
dim Filter 'As Redemption.TableFilter
dim Restr 'As Redemption.RestrictionProperty
dim Table 'As Redemption.MAPITable
Select Case PropName
Case "CompanyName"
PR_DISPLAY_NAME = &H3001001E
PR_COMPANY_NAME = &H3A16001E
PR_ANR = &H360C001E

set Table = CreateObject("Redemption.MAPITable")
Table.Item = Application.Session.AddressLists.Item("Companies").AddressEntries
'set up the restriction
set Filter = Table.Filter
Filter.Clear
set Restr = Filter.SetKind(RES_PROPERTY)
Restr.ulPropTag = PR_ANR
Restr.Relop = RELOP_EQ
Restr.lpProp = Item.CompanyName
Filter.Restrict
'restriction is done, read the data
Columns(0) = PR_DISPLAY_NAME
Columns(1) = PR_COMPANY_NAME
Table.Columns = Columns
Table.GoToFirst
Row = Table.GetRow
if Not IsEmpty(Row) Then
Item.CompanyName = Row(0)
End If
End Select
End Sub

I've tried changing the line: Item.CompanyName = Row(1), but it gives me a
Type Mis-match error "Unable to coerce parameter value. Unable to translate
your string."
Is there a way I can use this code to return just the FullName or the
CompanyName (either one because their both the same for my company items.
 
G

Guest

Well, after doing some research into PR_ANR, I got the impression that I would never be able to simply switch the line from:

Item.CompanyName = Row(0)

To Item.CompanyName = Row(1)

Columns(1) was supposed to be equal to PR_COMPANY_NAME, but it gives an error if anything other than PR_EMAIL_ADDRESS is used.

I figured out about it not resolving names if there is no FAX or Email address for an entry so I'm looping through and populating all the items that don't have a fax # already to use: (555)555-5555. Then parsing the string that is returned to just display the company name part of the string.

Thanks,

John
 
G

Guest

Well, I've got things working "OK" for this particular function, however I had to create a bogus BusinessFax number ((555)555-5555) for each company item in the companies folder, however I can't do this when linking other types of items (e.g. Contact to Manager) because I don't want to create bogus FAX numbers for them just so that they will show up as Auto-Complete entries.

How does Outlook "jump" to items so quickly when "in-cell editing" is turned off in folder view of items? If I highlight an item in my Companies folder and have the view sorted by "Company" then start typing, it jumps right to the item I'm looking for.

Why would this not be possible from a textbox without loading the entire list of items first? Also, once I find the Company that I'm looking for, I need to get it's associated EntryID which is not part of the recipient table and I don't know how to populate a custom field on my form that holds that string.

Does anyone know of an easier way to create an auto-complete textbox from items in a public folder where once an item is retrieved, I can populate an array with info like I would populate the columns of a combobox?

Thanks,

John
 
K

Ken Slovak - [MVP - Outlook]

I don't know how Outlook does things like that under the hood, but it's
something like a MAPI restriction or search. With enough work and ripping
your hair out you probably could replicate things like that :)




John Riddle said:
Well, I've got things working "OK" for this particular function, however I
had to create a bogus BusinessFax number ((555)555-5555) for each company
item in the companies folder, however I can't do this when linking other
types of items (e.g. Contact to Manager) because I don't want to create
bogus FAX numbers for them just so that they will show up as Auto-Complete
entries.
How does Outlook "jump" to items so quickly when "in-cell editing" is
turned off in folder view of items? If I highlight an item in my Companies
folder and have the view sorted by "Company" then start typing, it jumps
right to the item I'm looking for.
Why would this not be possible from a textbox without loading the entire
list of items first? Also, once I find the Company that I'm looking for, I
need to get it's associated EntryID which is not part of the recipient table
and I don't know how to populate a custom field on my form that holds that
string.
Does anyone know of an easier way to create an auto-complete textbox from
items in a public folder where once an item is retrieved, I can populate an
array with info like I would populate the columns of a combobox?
 
K

Ken Slovak - [MVP - Outlook]

To catch the beginning of a string use FL_PREFIX. That's used for any
type-ahead type thing or "begins with" search. For something like that I
would use Find/etc. instead of a Restrict.




John Riddle said:
I don't think that it could possibly be a restriction when you start
typing and it "jumps" to that contact on the list because that is done
hundreds of times a day here and it doesn't affect performance at all like
other restrictions do. I'm sure it is some method of Find/FindNext, but how
to capture the keystrokes and how to use a "Starts With" kind of matching
instead of FULLSTRING or SUBSTRING?
 

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