-- -- $Date: 2012/06/12 -- $Revision: 1.0.a -- -- fp_cid_search.scpt -- -- Searches for Caller ID Number of incoming FacetPhone call in Filemaker -- Contacts database. If Caller ID Number is not found then a new Record -- can be created. FacetPhone's "fp_cid" program used to retrieve Caller ID -- of the current or last call for logged in user sends back a reply like this: -- -- "" -- -- Assumes 10-digit phone numbers w/hyphens stored in contact records: -- -- Work Phone, Mobile Phone, and Home Phone -- -- For example: -- -- Work Phone: 972-985-9901 -- -- Tested on Mac OS X 10.7.4 with: -- -- FacetPhone v5.0, Build 715 -- AppleScript 2.2.1 -- FileMaker Pro 12.0v1 -- -- -- 2012/06/12 Eric Yundt - FacetCorp Support, support@facetcorp.com -- -- --------------------------------------------------------------------------- -- set cidLine to do shell script "/usr/facetphone_mac_utapi/bin/fp_cid -u $USER" set cidNum to text 9 thru ((offset of ">" in cidLine) - 1) of cidLine -- set cidNum to "1234567890" -- set cidNum to "No caller id" -- set cidNum to "103" if length of cidNum is 10 then set cidNum2 to text 1 thru 3 of cidNum & "-" & text 4 thru 6 of cidNum & "-" & text 7 thru -1 of cidNum else set cidNum2 to cidNum end if tell application "FileMaker Pro" tell database "Contacts" try show (every record whose cell "Work Phone" = cidNum2 or cell "Mobile Phone" = cidNum2 or cell "Home Phone" = cidNum2) on error try display dialog "Caller ID not found. [" & cidNum & "]" buttons {"Cancel", "Create New Record"} if result = {button returned:"Create New Record"} then set newRecord to create new record try if cidNum mod 1 is 0 then tell newRecord set cell "Work Phone" to cidNum2 end tell end if end try show newRecord end if end try end try end tell end tell