1 2 Previous Next 22 Replies Latest reply on Nov 16, 2016 9:26 AM by MacDevGuy

    USPS API Address Verification

    MacDevGuy

      DBservices have a post on their blog by Brendan McBride demonstrating how to verify addresses in Filemaker. It's very slick and the script he wrote is very nicely done. I suppose I will end up trying to reach him through the company page but I figured I would post here first and see if anyone had any thoughts or perhaps someone might be interested in the code example.

      Looking at the example template there's two tables but it appears that only one field is being used which is labeled " __kptID ". It occurs in the CUSTOMER table and also the
      PREFERENCES table. There's also a relationship link but it's got an X between the two.

      I was thinking that I could copy the code over and then re-point table references and field names to save some typing.

       

      When I created the table and a layout for PREFERENCES from the example file, Filemaker displays "  " and I am unable to do anything with the fields. I am guessing it's because I need to define a relationship between the two by linking them together and the kptID field is only to tie them together in the relationship graph.


      But the fact the example database has an X between the two tables in the table relationship graph is kind of confusing. So my question is: Does merely drawing the line between the two table relate them?


      Also upon inspection of the layouts and fields I see the uspsUserID is placed on the CUSTOMER table. I also see after creating a new layout called PREFERENCES the __kptID is running a calculation used to replace the contents which is: Get ( UUID )

      If you require more information or would like to take a look at the example files they can be found here:

      https://www.dbservices.com/articles/integrate-filemaker-usps-address-validation/

       

      If you have any thoughts on the example or guesses as to what the intention of the kpt_ID or how it's used I would love to hear them. I would love to send a message to Brendan but his email address is not listed and commenting in their blog is turned off. In addition I feel pretty confident that someone here might benefit from his example if they are interested in doing this sort of thing.

       

      TIA...

        • 1. Re: USPS API Address Verification
          schamblee

          I don't know anything about the example file by dbservices, but I have created my own db that will retrieve the mailing address with zip+4 from the usps website.  Dropbox - zipcode_usps.fmp12

          • 2. Re: USPS API Address Verification
            MacDevGuy

            So schamblee are you saying this verifies the address AND snags the zip+4? That would be even better I think.

            • 4. Re: USPS API Address Verification

              This is a cool capability, I didn't know about it.

               

              It's not clear to me if you're having trouble getting a response from USPS or trouble with FileMaker's implementation.

               

              I would try to split the two tasks:

               

              1. Try to just get a response given the URL, and then

              (Does this part work already?)

               

              2. Do something with data/tables in FileMaker.

               

              ---

               

              I'm going to play with this next week and see what I get.

               

              The link to the API in the article you included said it "moved", but navigating around, it looks like the link to sign up for a free account is:

               

              USPS - Web Tools Registration Web Page

               

              But, in any case, thanks for the heads up about this cool capability from the USPS.

               

              -- m

              • 5. Re: USPS API Address Verification
                MacDevGuy

                schamblee I will take a look at it. Brendan's example gives feedback in some cases. For example if the address is correct but more information is needed it will prompt the user telling them. e.g. "The address is correct but there are several units at this address and a unit number is missing." (Or something like that).

                 

                So what kind of error trapping is included?

                 

                Thanks for providing the file.

                • 6. Re: USPS API Address Verification
                  MacDevGuy

                  It's not clear to me if you're having trouble getting a response from USPS or trouble with FileMaker's implementation.

                   

                  I am not having trouble. I didn't make it. This work was contributed by Brendan McBride at DBservices. They have a blog with tips and tricks. I went to the USPS site and signed up for an ID and plugged my ID into the username field on the main layout and clicked "Validate" and it worked.


                  The link to the API in the article you included said it "moved", but navigating around, it looks like the link to sign up for a free account is:

                   

                  USPS - Web Tools Registration Web Page

                   

                  Yes I noticed it had moved as well.

                   

                  My questions about it were about how the _kpt_ID was used and if drawing the line to connect the two using this field in the table graph view was how it was establishing a connection between the two tables. It also used a UUID which I have never seen before.

                  • 7. Re: USPS API Address Verification

                    Check.

                     

                    Didn't mean to imply you were having trouble. Poor choice of words on my part.

                     

                    - m

                    • 8. Re: USPS API Address Verification
                      MacDevGuy

                      No problem Morkus. I was just glad to get some replies. heh!

                      • 9. Re: USPS API Address Verification
                        bmcbride

                        Hey MacDevGuy,

                         

                        The example file is using what is called a cartesian relationship. As long as the fields being referenced in the relationship have a value in them, FileMaker will evaluate it as true, and will therefore be able to pull data through that relationship. The example is referencing the primary key in both tables, which means both fields should always have some value in them.

                         

                        You will want to make sure that the tables you are using both have at least one record in them, and the necessary fields have been entered.

                        • 10. Re: USPS API Address Verification
                          MacDevGuy

                          Ah Brendan you are a good man! Thanks for taking the time to come and comment.

                           

                          I suspected as much but one never wants to assume. ;-)
                          I knew they were keys and I saw you had them set to use UUIDs. If I have other questions, do you mind if I ask them here?

                          • 11. Re: USPS API Address Verification
                            MacDevGuy

                            Brendan McBride wrote:

                             

                            Hey MacDevGuy,

                             

                            The example file is using what is called a cartesian relationship. As long as the fields being referenced in the relationship have a value in them, FileMaker will evaluate it as true, and will therefore be able to pull data through that relationship. The example is referencing the primary key in both tables, which means both fields should always have some value in them.

                             

                            You will want to make sure that the tables you are using both have at least one record in them, and the necessary fields have been entered.

                            bmcbride I have dug into the file and studied it a little closer. I also bumped into several articles on "connectors", one that comes to mind off the top of my head was the Todd Geist article. So what I see from the script is that you are getting the UUID and it serves as the __kptID in both tables which acts as the connector. Can this exist alongside of another primary key I am using? It also looks like it serves the purpose of populating some data to satisfy the "As long as the fields being referenced in the relationship have a value in them, FileMaker will evaluate it as true, and will therefore be able to pull data through that relationship" rule. Would that be correct?

                            • 12. Re: USPS API Address Verification
                              MacDevGuy

                              schamblee I took a look at the file you posted and it's pretty slick. I can see it would be very useful to many people.

                               

                              I like Brendan's example because it works with fields I have in place already and I get feedback prompts which tells me that it's working. I keep running into more and more discussions about developing databases for others where they discuss giving users feedback as things happen. This makes a lot of sense to me.

                               

                              I also like the fact that his example is commented and sectioned allowing me to see the process step by step. I reviewed your scripts though and they are very elegantly written. Very concise and short. That's an art in and of itself.

                              • 13. Re: USPS API Address Verification
                                bmcbride

                                I like to use the function Get ( UUID ) to populate my primary keys as the chance for having duplicate values is next to zero, and I have had issues with serial numbers and syncing records with offline copies of a database. The UUID has become a habit. However, if you are using some other method for setting up primary keys, serial number for example, the cartesian relationship that I am using will work just the same when going from a UUID field to a serial number field.

                                • 14. Re: USPS API Address Verification
                                  schamblee

                                  I was not comparing my file to Brendan's, I have very little time in my file.  It was a sample I created for another user on this forum so I created it in about a day, so I did not comment my file.  I tried using descriptive names in the fields.  My sample does not use the API, it just retrieves the data from the USPS website.  It is very simple to integrate into your own file.  Commenting your work is the best practice, but I was trying to post a response in a timely manner and never have went back to comment my work in the database.     

                                   

                                  Use the file that suit your needs.  I posted it as another option, other users on another post stated it meet their needs.

                                  1 2 Previous Next