admin管理员组文章数量:1391934
I am trying to fetch the birthday of a contact in the contacts list, on Mac.
tell application "Contacts"
set firstContact to first person
set contactName to name of firstContact
set contactBirthday to birthday of firstContact
end tell
-- Display the information
display dialog "Name: " & contactName & return & "Birthday: " & (contactBirthday as string)
This errors:
tmp.scpt:136:144: execution error: Contacts got an error: Can’t make birthday of person id "0BC1D...48B:ABPerson" into type specifier. (-1700)
How to solve this? The contact has a birthday set indeed.
I am trying to fetch the birthday of a contact in the contacts list, on Mac.
tell application "Contacts"
set firstContact to first person
set contactName to name of firstContact
set contactBirthday to birthday of firstContact
end tell
-- Display the information
display dialog "Name: " & contactName & return & "Birthday: " & (contactBirthday as string)
This errors:
tmp.scpt:136:144: execution error: Contacts got an error: Can’t make birthday of person id "0BC1D...48B:ABPerson" into type specifier. (-1700)
How to solve this? The contact has a birthday set indeed.
Share Improve this question asked Mar 13 at 13:31 Ionică BizăuIonică Bizău 114k94 gold badges310 silver badges487 bronze badges 1 |1 Answer
Reset to default 1You will find File:Open Dictionary… in Script Editor invaluable for tracking down this sort of problem. Open the dictionary for Contacts and search for “birth” or (because there are a few date fields built into the system) “date”.
In this case the solution is a simple one: the name of the property isn’t birthday
but rather birth date
. Change birthday
to birth date
and your script works.
tell application "Contacts"
set firstContact to first person
set contactName to name of firstContact
set contactBirthday to birth date of firstContact
end tell
-- Display the information
display dialog "Name: " & contactName & return & "Birthday: " & (contactBirthday as string)
You may also find it useful to use Script Editor for testing thorny problems like this, even when your end result will be a command-line script or a snippet of code in another application. In this example, while the error text remains somewhat obscure, Script Editor will helpfully highlight the offending code.
The word “birthday” is very helpfully highlighted: that’s where Script Editor thinks the error occurred. If you look closely you can also see that valid properties (in this example, name) are displayed using a different color than other parts of the code. Script Editor is very useful for testing AppleScript code when the code can be broken into small parts.
本文标签: macosFetching contact39s birthday in Apple ScriptStack Overflow
版权声明:本文标题:macos - Fetching contact's birthday in Apple Script - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744697661a2620377.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
birthday
in the dictionary. Doesbirth date of firstContact
work? – Willeke Commented Mar 13 at 15:03