Components | All | New | MacOS | Windows | Linux | iOS | ||||
Examples | Mac & Win | Server | Client | Guides | Statistic | FMM | Blog | Deprecated | Old |
Sets the value of a contact.
Component | Version | macOS | Windows | Linux | Server | iOS SDK |
Contacts | 8.4 | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |
Parameter | Description | Example | Flags |
---|---|---|---|
ContactIdentifier | The contact identifier. | "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" | |
Selector | Which value to set. | "givenName" | |
Value | The value to set. | "Test" | Optional |
Returns OK or error.
Set given name fo ra contact:
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "givenName"; "Joe" ) ]
Clear email for contact:
// first set email list to empty JSON array:
MBS( "CNContact.SetValue"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson"; "emailAddresses"; "[]") &
// and save
MBS( "CNContactStore.UpdateContact"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson" )
Set email list with two emails:
// set email address list:
MBS( "CNContact.Value"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson"; "emailAddresses"; "[{ \"label\" : \"_$!<Home>!$_\", \"value\" : \"home@test.de\" }, { \"label\" : \"My Label\", \"value\" : \"private@test.de\" } ]") &
// and save
MBS( "CNContactStore.UpdateContact"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson" )
Set birthday:
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "Birthday"; "{\"day\":\"27\",\"month\":\"12\",\"year\":\"1963\"}") ]
Set birthday with variables to build JSON:
Set Variable [ $birthday ; Value: JSONSetElement ( "{}" ; ["day" ; $day ; JSONNumber]; ["month" ; $month ; JSONNumber]; ["year" ; $year ; JSONNumber] ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "Birthday"; $birthday) ]
Set contact to be organization:
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "Type"; "Organization") ]
Set notes field for contact:
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "Note"; "Hello World!") ]
# required additional entitlements for FileMaker and may not work in macOS Ventura.
Sets the note field for a contact via AppleScript functions:
# Set Contact Note via AppleScript
Set Variable [ $theID ; Value: "773E1A42-ABCD-4CCF-88DE-E9C64BEE6D33:ABPerson" ]
Set Variable [ $theNote ; Value: "Best Hotdogs in town!" ]
# Compile AppleScript
Set Variable [ $ScriptID ; Value: MBS( "AppleScript.Compile"; "property theID : \"\"¶ property theNote : \"\"¶ tell application \"Contacts\"¶ set theContact to the first person whose id is theID¶ set note of theContact to theNote¶ save¶ return note of theContact¶ end tell" ) ]
Show Custom Dialog [ "Result from AppleScript" ; MBS( "AppleScript.LastError" ) & ¶ & MBS( "AppleScript.LastErrorMessage" ) ]
# run a query or multiple
Set Variable [ $r ; Value: MBS( "AppleScript.SetPropertyValue"; $ScriptID; "theID"; $theID ) ]
Set Variable [ $r ; Value: MBS( "AppleScript.SetPropertyValue"; $ScriptID; "theNote"; $theNote ) ]
Set Variable [ $result ; Value: MBS( "AppleScript.Execute"; $ScriptID) ]
Show Custom Dialog [ "Result from AppleScript" ; $result & ¶ & MBS( "AppleScript.LastError" ) & ¶ & MBS( "AppleScript.LastErrorMessage" ) ]
# free memory
Set Variable [ $r ; Value: MBS( "AppleScript.Close"; $ScriptID) ]
This function checks for a license.
Created 1st August 2018, last changed 23th December 2023