03. Push Contacts [9:56]

Description: This video demonstrates FileMaker Pro pushing contact data to Microsoft Outlook.



In this video were going to look at exchanging data between FileMaker and Outlook. Let’s get started. First you open the folder that you downloaded and open up the demo file, specifically the beginner demo. This file is a lot easier to learn the plug-in with because we’ve reduced the number of script steps and just included the bare minimum to provide an example of the functions were about to look at.


So, as you open up the demo, you’ll be directed to this first page with two important steps; the “registration” and the “authenticate”.  The registration process is outlined in another video as well the documentation so we won’t go into detail about that here. But, it is important that the plug-in is registered before we attempt use any part of the demo. And then, we want to authenticate with Outlook, ensure that Outlook is up and running and operational. And in this case I’ve got Outlook set up and you can see my different modules. I’m focused on contacts here and i’ve simply just hid the folders so that we have more room to look at the data and I’m in the list view at this point. So, back to FileMaker. Let’s authenticate. What that does is it establish a communication between FileMaker and Outlook. That’s a one-time situation – the authenticate only needs to be called once per FileMaker session. So  once you open FileMaker you can register the plug-in, call authenticate, and from that point on you can communicate back and forth with the plug-in without incident.


1:58 Probably the easiest thing to start with is a simple push from FileMaker to Outlook in the Contacts module. So, in our beginner demo here, we have John Smith set up in a few simple fields here in FileMaker and some buttons below. I can click insert, and the moment I do, it returns to me the Outlook ID. So let’s go take a look at that in Outlook — sure enough, John Smith has been created. And if I want to make a quick edit, I can change John to Johnny and click “edit” and it will use that same ID and edit the record. So a new feature in Outlook Manipulator v4 is that you can now click the view button and it will bring up Johnny Smith in Outlook on the detail pane. As you can see here we have the same data being pushed. In this case we’re just pushing the company name and the full name and e-mail. And finally, using this ID I can delete Johnny Smith right from Outlook. So, back to Outlook, you can see Johnny Smith is no longer there. So to recap, with this one sample we can add contacts, we can edit contacts and we can delete contacts from FileMaker to Outlook.


3:29 So let’s take a look under the hood to see how the scripts operate. If I look at the insert button and see, we’re calling the script “Contacts Enter Into Outlook.”  So let’s take a look at that script. So, the very first thing we do is call the “plug-in checker” script which is another script that does what I mentioned earlier-which is it verifies that the plug-in is installed, it verifies that the plug-in has been registered and that it’s working in either demo mode or live mode. And that’s just good housekeeping before we do anything with the plug-in. And again, that can be called in a whole other script in your solution like it is here or you could call it before every time you talk to the plug-in if you’re not sure when that plug-in is going to be called. Again, it depends on your environment and how you want to set up your system.


4:28 So then there’s the “Authenticate” command and that’s also formatted as a subscript in this example. Once those two scripts are called, we begin by calling a command called “open folder”.  And the folder we’re opening in this case is simply named contacts. This tells the plug-in what area of Outlook we want to communicate with.  So in this example, I’m pulling from a  field here because I’ve stored the word “contacts” in a global in my solution but you would use the words contacts, calendar, mail, or I should say inbox and tasks if you wanted to talk to any of those modules in Outlook. Then the next command is “new record”.  Simply put, this creates a new record in Outlook. Now, the moment this command is called a record won’t immediately appear in Outlook. It won’t appear until you call the “Save Record” command later in this script series. But, it creates a new record in memory of Outlook and awaits for you to set the fields. And that’s what these fields do down here. We’re simply calling a command called “PCEM_SetFieldData”.  I’m using a global variable to store the results of this script step. And this particular command requires two parameters. The first parameter is the name of the field in Outlook that you want to set and then the second parameter is simply the data you are setting in that field. So, again this is a reserved name; First name” is a reserved field name in Outlook. And you get the whole list of field names in a document called fields and functions at comes included in the package. That will give you a list of all the modules in all the fields and the field names that you need to communicate with.


6:25 So, in this case we are simply grabbing that field that you saw in the layout earlier and setting the data within. And we’re doing the same thing for last name, company and e-mail. So I’m setting four Outlook fields with data from FileMaker and then I’m calling the “Save Record” command.  And it’s simply that – there are no parameters, it’s just PCEM_Save Record. Once you do that, what’s returned to you the moment you call that command, is the Oulook ID.  so the Outlook ID in this case is going to be stored in the field in FileMaker called “gContactsOultookID”.  Now if I would receive some sort of an error, instead of giving me an Outlook ID, it would give me the word “error”. And in this case were showing the error in a dialog. Now there are any number of reasons you could get errors.  If you pass the registration portion and authenticate and using all the right-field names here, the chances are very slim that you will get any kind of error on save record. So that’s the basic enter into Outlook script within contacts.


7:40 And the good news is that all these modules work similarly. Pushing the contact is almost identical to pushing the calendar or pushing a note, or pushing a task. It’s just the only differences the open folder command is different, where instead of calling contacts, you’ll be calling tasks. And of course the fields are different, the field names are different. But other than that the whole idea is identical. So that’s the “add to contacts.”  Let’s look at editing…


8:14 So that script is here. And what we first do in this case is we’re determining if there is already an ID in FileMaker captured for this particular contact. So we’re saying here is if there is no contact ID for Outlook already, or if there’s a negative, then we warn the user you can not edit a record until you supply a valid Outlook ID. So once it passes this test we again perform the plug-in checker, the authenticate command. So in this case, it’s a little different. Instead of calling the

“PCEM_NewRecord” command, we’re calling the “”PCEM_OpenRecord.” In this particular command requires that we supply a valid Outlook ID.  This tells Outlook what record we want to edit. And just like in new record, we set the field, set the field, set the field and save record.  All of this is completely identical to new record.


9:22 So in a sense, we’re looking up the record in Outlook and replacing all the values that exist with the new values here and saving the record just like we did when we created a new one. Again we do a error check to see if that worked fine. And that’s Edit.  Let’s look at how to delete a contact. So again we call the plug-in checker and the authenticate script steps. And in a single command, we call the “PCEM_DeleteRecord.”


9:57 And the first parameter of that is the Outlook ID so we’ll again give it the Outlook ID so that Outlook knows what record we want to delete and it will delete it. This second parameter here you can read more details in the documentation about that. But this determines if the contact it is going to be sent to the deleted items folder in Outlook (which by the way is a lot quicker way to delete a contact) or if it’s going to be a permanent delete. In this case I believe we’ve set up so that it moves it by default to the deleted items folder. So then we do a quick error check and that’s it. The only other thing we’re doing here in this script is that we are clearing the Outlook ID because essentially if this worked, that Outlook ID we don’t want to have lingered in FileMaker we want to delete that Outlook ID and then we commit the record. So that’s insert, edit, delete within the demo here.


11:01 Let’s quickly look at how to view a contact. So we call that that “Display in Outlook.” This also is quite easy. You simply call the “open record” command and give it the Outlook ID that you stored in FileMaker. And then you call the command “PCEM_Display” and that will display the detail view of the contact, calendar, task or what have you that you want to look at.

Tags: , , , , ,