Daniel Shanahan Posted May 10, 2010 Posted May 10, 2010 I have an Applescript that moves data from FMP to Address Book. It works fine, except when data is missing in FMP. Here is the Applescript: tell current record set theFirstName to cellValue of cell "name_first" set theLastName to cellValue of cell "name_last" set theTitle to cellValue of cell "title" set theOrg to cellValue of cell "company_name" set theAdd to cellValue of cell "shipping_address_1" set theAdd2 to cellValue of cell "shipping_address_2" set theCity to cellValue of cell "shipping_city" set theState to cellValue of cell "shipping_state" set theZip to cellValue of cell "shipping_zip" end tell tell application "Address Book" activate set thePerson to make new person with properties {first name:theFirstName, last name:theLastName, job title:theTitle, organization:theOrg} make new address at end of addresses of thePerson with properties {label:"Work", street:theAdd & return & theAdd2, city:theCity, state:theState, zip:theZip} save addressbook end tell Not everyone has a Title. For those who do, the data transfers fine. However, if Title is blank in FMP, something happens when it is pushed to Address Book - it seems like AB locks that field or sets it to NULL or something. When I am in "Edit" mode in AB, I tab through the fields, but I cannot tab into the Job Title field. Is there a way to say something like, if theTitle is not missing values then theTitle, else leave it alone (and make it editable within AB). I would really like to use such a condition on all the fields, just to make sure values are passed. Thanks.
Daniel Shanahan Posted May 12, 2010 Author Posted May 12, 2010 To demonstrate the problem, I've included a file - AB_exp_MissVal.fp7 There are three records: John Doe has a title, so everything moves to AddressBook properly. Jane Smith has no title. Once in AddressBook, in the Edit mode, I am unable to tab into the Job Title field to enter data. Jones has neither a first name nor a title. Again, in AddressBook, in the Edit mode, I am unable to tab into the First Name field and the Job field. In a way, this behavior is fine because it forces the user to make edits in the FMP data set. Nonetheless, I'm curious if there is a way to trap for Missing Values while I set the properties. In other words, if the value exists, set that property, otherwise, skip that property altogether. Can anyone offer any insights? Thanks. AB_expt_MissVal.fp7.zip
Fenton Posted May 12, 2010 Posted May 12, 2010 One thing you could do is check for a value before setting it into Address Book. Set FileMaker data into a variable, then check the variable. if aTitle ≠ "" then -- set into AB end if
Daniel Shanahan Posted May 13, 2010 Author Posted May 13, 2010 Thanks, Fenton. Then, will I need to do something where I set the properties? For instance, if I do this (abbreviated) set theFirst to cellValue of cell "name_first" set theLast to cellValue of cell "name_last" if theTitle ≠ "" then set theTitle to cellValue of cell "title" end if ... (in Address Book) set thePerson to make new person with properties {first name: theFirst, last name: theLast, job title: theTitle} etc. The code above will produce an error message that says the variable theTitle is undefined.
Genelia Posted April 13, 2011 Posted April 13, 2011 Is it possible to get back data from address book to Filemaker File? Thanks, Fenton. Then, will I need to do something where I set the properties? For instance, if I do this (abbreviated) set theFirst to cellValue of cell "name_first" set theLast to cellValue of cell "name_last" if theTitle ≠ "" then set theTitle to cellValue of cell "title" end if ... (in Address Book) set thePerson to make new person with properties {first name: theFirst, last name: theLast, job title: theTitle} etc. The code above will produce an error message that says the variable theTitle is undefined.
Recommended Posts
This topic is 4971 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now