05. Training – Part 2 [11:42]

**This product has been discontinued as of May 10, 2016.**

Description: This video explains the following:

  1. Import all Contacts.
  2. Import all contacts by List.
  3. Import Updated Contacts.

Transcript:

In this video we’re going to look at the scripts and integration steps in order to:

  • Import all your lists
  • Import contacts by list
  • Import updated contacts

0:22 Let’s begin by opening our FileMaker demo file and the first step is I do need to authenticate with my Constant Contact account here, and that’s simply by calling the “PCXP_Authenticate” function. What we’re going to do here is we’re actually going to step into the “ImportLists” script. So let my open up Debugger here and what I’m going to do is select “Import Lists” and we’ll open the Data Viewer back to back here. And what I’ll do is we have some checkers here, where we’re checking to make sure for the Mode, the Authentication, Plug-in Checker scripts so I’m just going to skip over all of these FileMaker commands and let’s go right to our first plug-in function call here which is “GetAllLists”. We’re going to go ahead and play through to that here, and here we are calling the “GetAllLists” function and that is retrieving all of our lists and it returns as you can see a date/time stamp here that is from Constant Contact. Next we’re going to check for errors, and let’s go down to our next function call here; for good measure in the demo file we delete all of the records here and re-center the current window. And now we’re on to our next function call which is “GetFirstList”; so GetFirstList is going to retrieve the name of the first list which is you can see is called “active” here. We of course are then checking for errors, and if the result equals “END” then we would stop the script. We’re continuing in through our loop and here we’re just getting the list fields, so right now we’re just getting the list fields in a list, lists not only have names, they also have short names, they have sort orders, there’s an opt in default, now these are all discussed on our documentation so I encourage you to also read the Developer’s Guide and the Functions Guide. And we’re going to end our loop if our result is “END”, which it is not, so we’re actually going to continue through here. Hopefully you can see what I’m doing, let me expand the window a little bit more, so all that we’re doing is now we’re going to go back in and we’re going to continue to get all of the additional lists that we have. We’re basically calling the “GetAllLists”, “GetFirstList”, then we’re getting the list fields that we want using the “GetListField” function, then we’re calling “GetNextList” and just iterating through all of the lists that are available to us. So as you can see now I’m getting the “do-not-mail” list here, and now I’m getting the “removed” list here, and then I’m getting the next list which, as you can see the next list returns a “1” and that’s because that’s the actual list ID. So lists have names and then they actually also have unique list ID’s. There are three lists in Constant Contact that don’t give you ID’s, and those ones we got previously, and those lists were the “Active”, “Do Not Mail”, and “Removed” list. All other lists in Constant Contact are going to have a list ID that they’re going to return. And we’ll just go through and get all of the fields; we’re going to get the next list here, and I’ll put my marker right there because I believe I have about 11 lists. So you can kind of see me here going through and entering my loop, getting all of the lists and all of the list fields here. Some of my lists I’ve deleted so that’s why my list ID’s might be jumping from 7 to 9, previously I deleted my List 8. And now we’ve returned an “END” so we’re exiting that loop and if we go into our FileMaker file you should see that I have all of my 12 lists here.

4:44 Now if we kind of just want to open this script up to see it under the hood, rather than in Debugger, let’s do that as well. I’m going to open the “Import All Lists” script, and as you can see here, let’s go down to our very first function call which is called “GetAllLists”.  Then we’re doing our error trapping here, then if we go down to the next function call we are getting the first list, again performing our error trapping, then we are going to enter our loop and we’re going to get all of the list fields using the “GetListField” function, and passing any of the list fields that we’d like to obtain. And then we’re calling the “GetNextList” in order to continue looping through and getting all of the lists in our count. And that’s it.

5:30 Now let’s look at importing contacts because that also is very similar. So here we’re going to go into the “Import All Contacts” script, and I’ll just walk through this script with you. I’ll go down to our very first function call, which right here is just called “GetFirstList”. Now we do that just to make sure we’re getting the correct list, as you can see immediately after we have a subsequent call to “GetListField”, and we’re retrieving the name of that list. Then we enter our loop; get the next list, until the result equals “END”. And we also check to see if the list is empty, now this isn’t anything that you have to do, but for good measure it doesn’t hurt. We actually are checking by calling the “GetListField” to make sure that the contact count is greater than “0”, or in this case if it equals “0” we show a custom dialog to the user that there are no records found in this list to retrieve. Once you get past the step of getting the list name and confirming that contacts actually exist in the list, than we can begin our next function call. If we scroll down all this scripting; because again that’s just FileMaker scripting and you are developers so we’re dealing strictly with our plug-in function calls in this video, we go down to the “PCXP_GetContactsFromList” so this is going to be our function that is going to begin retrieving the contacts from the list that we specified. For good measure we do check for errors here, we delete all the records so we can start fresh in our demo file.

7:01 Then we begin to iterate through the contacts here by calling “GetFirstContact” right, rather than call “GetFirstList” as we saw with importing all of our lists. We are now calling “GetFirstContact”, checking for errors, and then getting the contact fields that we desire. In this case we’re getting the email address first, then we’re calling “GetNextContact”, and we’re entering our loop, getting the email address contact field for the next contact up here, and then calling “GetNextContact” and basically just looping through until we get all of our contacts. Now you certainly can also get additional fields, we don’t have to just get the email address field. If you want a list of all available contact fields or list fields, you can open up the documentation here, it’s the Functions Guide, and at the very end of the Functions Guide there is a section called “Available Constant Contact Fields”, here you can see all of the available contact fields, here’s the field name, the method – if you can Get them or Set them, acceptable values and notes. And here are all the fields for contacts and here are all of the fields for lists. So that is where the available list fields are coming from. So that’s really how you import all of your contacts. Basically, just to kind of sum that all up again, you are going to be calling  the “GetAllContacts”, “GetFirstContact”, “GetContactField”, specify all of your contacts fields, and then call “GetNextContact”, if the result does not equal “END” to loop through and get all of your contacts. And remember for good measure we are looking to make sure that our lists do indeed have contacts in there count.

8:45 Next let’s go ahead and look at the scripts in order to import updated contacts. Because we do have a function in here called “GetUpdates”, and this function allows you to retrieve all of the contacts that have been updated since the previous date passed to the “Since Date” parameter. So we’ll go ahead and look at that here, the “Import Contacts” script, let’s go right down to our very first function call which is right here, and that’s the “GetUpdates” function. And if were to open the Data Viewer and let’s navigate to “Watch” and take a look at the raw function here. Let’s go to call the “GetUpdates” function here, you can see that there are two parameters, there’s a “Since Date” parameter and this “Since Date” parameter is where we’re actually  going to pass the date that we want to check on. And we’re basically going to retrieve all of the contacts that have been updated since this previous date passed to this parameter and we also need to pass the “ListTypeOrID” as well to this function. So I’ll go ahead and cancel this here, and let’s go back into our script. And quite simply we just call the “GetUpdates” function, we pass a date/time stamp, and a list ID or ID, and then we’re going to follow very similar steps. We’re going to call the “GetFirstContact”, we’re going to check for errors, next function call is down here where we’re calling the “GetContactField” and we’re just getting the email address field, of course you can get more contact fields if desired. Then we’re calling the “GetNextContact” and looping through until our result equals “END”. And that’s it, that’s basically how you import all of your contacts and import all of your updated contacts.

10:40 I encourage you to download the demo, get under the hood, reverse engineer our scripting, read the documentation. We have various tools available for you in order to learn how to work with plug-in functions. Whether you’re a seasoned developer or just starting to learn scripting in FileMaker, we try to make various different learning methods and tools available for you to learn how to work with plug-in functions. Now we can begin to integrate the plug-in into your FileMaker solution. Please make sure you utilize all available tools we provide, such as additional training videos, documentation, and reverse engineer the demo file. If you need additional assistance please contact us via email, phone, or browse our forum if you have any questions. We are happy to assist with any integration steps or even design a solution for you. Thanks you for watching and we hope you enjoy eMail Marketing and connecting FileMaker and Constant Contact.