1
votes

I have the following applescript to add contacts from the command line

on run {firstName, lastName, workPhone, mobilePhone, workstreet, workzip, workcity, snr}
    tell application "Contacts"
        set theDate to current date
        if theDate is not missing value then
            set theDate to current date
        else
            set theDate to current date
        end if
        set thePerson to make new person with properties {first name:firstName, last name:lastName}
        tell thePerson
            make new phone at end of phones with properties {label:"Work", value:workPhone}
            make new phone at end of phones with properties {label:"Mobile", value:mobilePhone}
            make new address at end of addresses with properties {label:"Work", street:workstreet, city:workcity, zip:workzip}
            make new custom date at end of custom dates with properties {label:"Aufnahme", value:theDate}
            make new social profile at end of social profiles with properties {service name:"Schadennummer", user name:snr}
        end tell
        save
    end tell
end run

if I run

osascript kontakt.scpt Donald Duck 0133333 012345678999 Gansweg 11111 Entenhausen 120-RS-16-831222-2

i get the following

missing value

1
to know where issue is, you should add some log to see where your script gets the missing value. for your log, you can use write to text file or, much easier, add some lines 'say "step X" ' to your script. - pbell
How can i add a log for applescript? - Felix de Courten
you can add instructions say "A" , say "B" in your script : Your mac will tell you "A", "B",... and you will know where it fail. An other option is to write in text file : 1) create a file "Log.txt" on your Desktop with TextEdit (convert to basic text). 2) in your script, add instructions like : do shell script "echo step1 >> /Users/UID/Desktop/Log.txt" (replace UID by your user name, and 'step1' by appropriate trace). Each time your script will write "step1", "step2",...in your text file. looking to text at the end, you will see last log recorded. - pbell

1 Answers

2
votes

AppleScript returns the result of the last command/expression/statement, if any. In this case it's the result of the save command, missing value, which is probably just a quirk of Contacts' implementation. If you don't want to see a result, stick a simple return statement at the end of the script so that it returns nothing.