Problem with User-defined fields not appearing in some Views

  • Thread starter Sue Mosher [MVP-Outlook]
  • Start date
S

Sue Mosher [MVP-Outlook]

The only possibly tricky step is #3 -- the field names and data types need
to be identical to those defined in your custom form.

In #5, you set the message class as the argument for your
MAPIFolder.Items.Add statement, right?

The icon problem suggests that the "note icon" items are using a custom form
for which no icon was defined. Check the Message Class field for starters.
 
R

Roman Spanner

I have created an Outlook solution for a client which uses a custom form to
view contact data imported from ACT! 6. Data was imported into existing
contact fields but most went into user-defined fields that I created in the
folder.

The problem they are having is that some of the user-defined fields do not
appear in the Field Chooser ("user-defined fields in folder"), as they wish
to add those fields to custom views. I suspect this is a result of the way I
setup the folder, user-defined fields and importing of the data, but am not
sure so was hoping someone could confirm whether the procedure I followed
was correct, or not(!).

I did the following;

(1) exported contact data from an ACT! 6 database into an Access database
(using third-party tool)
(2) created a contact folder in a local PST file
(3) changed the view of the folder to Phone List and then created the
user-defined fields using the Field Chooser (after selecting "User-defined
fields in folder")
(4) published the custom form to the folder, with an appropriate message
class, but left the folder's default form as the standard contact form
(5) created the new contacts in the folder (using a VB application I
developed), setting the contacts message class to the one in (4)
(6) set the folder's default form to my custom form
(7) moved the folder into the Public Folders on their Exchange Server

I did (2) and (7) for reasons of speed, as I had 5000 contacts to import. I
also didn't set the folder's default form to my custom form for the same
reason - I was using the Outlook automation in my VB code.

The form was developed against a folder created on my own Exchange Server at
my office, but was setup using the same method as above.

Additionally, some of the contacts in the "Phone List" view have Post icon
next to them, rather than a Contact icon.

N.B. I am hoping to gain VPN access to there server soon such that I can
make an changes necessary to fix these issues.

Many thanks in advance for your advice.

Phil
 
R

Roman Spanner

Sue, thanks for replying so quickly!

In response to your queries...
need to be identical to those defined in your custom form.
I had a spreadsheet with a list of all the user-defined fields required and
their data types, which I used to "copy and paste" the names when creating
the fields. It's possible I made a mistake when using this. If I find that I
have made a typo, presumably I could;
(1) create the field in the folder
(2) write some code that would iterate through each contact item to create
the new field, set it's value to the one in the incorrect field and then
remove the old field
(3) publish a new version of the form using the new field

??
MAPIFolder.Items.Add statement, right?
Erm, no. I used the Oulook Object Library, rather than CDO, so my code looks
something like this;

Dim outOutlook As Outlook.Application
Dim outContactsFolder As Outlook.mapiFolder
Dim outContact As Outlook.ContactItem
Dim outContact As Outlook.ContactItem
Dim outUserProperty As Outlook.ItemProperty

Set outOutlook = New Outlook.Application
Set outNamespace = outOutlook.GetNamespace("MAPI")
Set outContactsFolder = outNamespace.GetFolderFromID(strDestinationFolderID)

# loop through contacts in database
Set outContact = outContactsFolder.Items.Add()
# loop through fields to be set
# if field is user-defined
Set outUserProperty =
outContact.UserProperties.Add(#FieldName#,#FieldType#,True)
outUserProperty.Value = #FieldValue#
# else
outContact.ItemProperties(#FieldName#).Value = #FieldValue#
# end if
#next
outContact.MessageClass = #CustomFormClass#
outContact.Save
Set outContact = Nothing
#next

I've used the # to pseudo-ise(!) the code. I use a mapping database to
define the Outlook field into which the ACT data is written, hence the "#
loop through fields to be set".
form for which no icon was defined.
Does that mean that there is a way of defining an icon to be used by a
custom form?
I will, as soon as the company provides me with VPN access to the network
and Exchange server! :)

Cheers,

Phil
 
S

Sue Mosher [MVP-Outlook]

Next time, use this syntax to create an item with a particular message
class:

Set outContact = outContactsFolder.Items.Add(#CustomFormClass#)

The properties should be defined in the form and visible as "user-defined
fields in this item." You won't need to add any UserProperties because
they're already defined in the form. Instead you just set their values.

Adding new fields to items at this point will one-off the items. Bad idea.
Instead, if you need to make adjustments, do it in the form first and
republish the form. Then set the properties in the items that use that form.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
R

Roman Spanner

Sue,

Many thanks for that. It looks like I will have to write some code that will
remedy all of this - this solution is live at the client's site so I will
have to sort it out somehow, retaining any changes that they've made to the
contacts since the initial import was performed. :-(

What's the best way for me to solve this?

Should I ensure that all the user-defined fields are created in the folder
first? If so, should I do this whilst in design-mode of the form, or using
my original method (via the Field Chooser in the Phone List view of the
folder)?

I forgot to mention before that although some of my user-defined fields
didn't appear in the Field Chooser in the Phone List view, they appear fine
(with values) when you open a contact. Is it just a case of defining the
fields again in the folder? Will they, and their respective values, then
appear when added to the Phone List view? (I hope all that makes sense!)

How do I fix "one-off"ed items? Don't I just reset the MessageClass for the
item?

I'm annoyed with myself as I thought I was doing things correctly, but it
looks like I was wrong. :-(

Cheers.

Phil
 
S

Sue Mosher [MVP-Outlook]

The ideal solution is to have the fields defined both in the folder, so you
can use them in views (and in Find and Restrict) code and in the custom
form, which will ensure they're defined for each item that uses the form.
See http://www.outlookcode.com/d/fields.htm . If you create the field first
in the folder, then drag it onto the form, you've accomplished both.

For one-off items, it's not just a matter of changing the message class. You
must use REdemption or CDO to remove some MAPI properties. Sample code at
http://www.cdolive.net/download/CleanUpOneOff.zip

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
P

Philip Street

Sue,

Many thanks again for your assistance with this. I will try your suggestions
and let you/the group know how I get on.

Cheers,

Phil
 
P

Philip Street

I'm trying to rectify the problem of the one-off items you were assisting me
with recently. The thing that I'm trying to do is "backup" the data that's
been entered into the one-offed items but I am unable to access the values.
What I mean by this is that I know that a particular item has values for
some of the user-defined fields that I created, albeit incorrectly, and I
want to read these values out and write them into a database such that I can
write them back in once I've fixed the folder, fields and form.

I've tried using the following two bits of code, but they don't work;

varValue = cdoMessage.Fields(strField).Value ' using CDO

and

varValue = outContactItem.UserProperties(strField).Value ' using the
Outlook object model

Neither yield the value that I know is in the item (by opening the item,
it's displayed in the form).

Can you tell me what I'm doing wrong? Should I be able to extract the
values from user-defined fields in a one-offed item?

Many thanks in advance,

Philip Street
 
S

Sue Mosher [MVP-Outlook]

Yes, you should be able to extract user-defined field data from an one-off
form item using the syntax below. I can only imagine that you have a typo in
the field name. Check the All Fields tab.
 
P

Philip Street

Sue,

I've now displayed the All Fields tab on my custom form and have found the
following.

I've opened one of the items and found that some of my user-defined fields
are displayed in the "user-defined fields in item". One of those fields
("Contract Value") has a value ("£12,000.00"), in this view, but when I
display the "user-defined fields in folder" view, the same field is listed
but without a value. Do you know the cause of this behaviour, and how it
might be fixed?

You recall that I mentioned before that some of the items an a Post icon
next to them rather than a Contact icon, in the Phone List view. Well, I've
just created a new contact and this also has a Post icon. This appears to
happen for all new contacts created with the form. Any ideas about this as
well?

As ever, you assistance is much appreciated. I didn't realise custom Outlook
solutions could be so tortuous!

Cheers,

Phil

p.s. I've ran the "clean one-off items" code you've suggested against all
the contacts, but am not sure whether it worked or not - how do I check?
 
P

Philip Street

Sue,

I hang my head in shame...

I've discovered that the field I mentioned ("Contract Value") was actually
wrong. On my form, the field name is "Contract Value " - notice the space at
the end - but I defined it in the folder as "Contract Value"! This was the
main field that was causing the problem, so I should be able to fix this now
that I know the nature of the problem.

With regards to the other issue - new contacts appearing with a Post icon
instead of a Contact icon - could this be caused by a form that uses fields
that have not been defined in the folder? I'm thinking in particular about
the issue above.

Cheers,

Phil
 
S

Sue Mosher [MVP-Outlook]

Sounds like you didn't set an icon on the (Properties) page of the form.
 
P

Philip Street

Sue,

Would that be the "Picture" property on the Advanced Properties page - I
can't see an icon property anywhere?

Cheers,

Phil
 
P

Philip Street

Ignore that last message I've found it - on the Properties tab of the form
itself...jeez, I'm going blind!

All I need to do now is find the small and large icon files for the classic
Outlook Contact...anyone?

Phil
 
P

Philip Street

Found 'em... :)

Phil

Philip Street said:
Ignore that last message I've found it - on the Properties tab of the form
itself...jeez, I'm going blind!

All I need to do now is find the small and large icon files for the classic
Outlook Contact...anyone?

Phil
 

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