Jump to content
Server Maintenance This Week. ×

Missing Value to Address Book


This topic is 4763 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 10 months later...

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.

Link to comment
Share on other sites

This topic is 4763 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.