CNContact.SetValue
------------------

Sets the value of a contact.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Contacts](component_Contacts.md) | [8.4](newinversion84.md) | ✅ Yes | ❌ No | ❌ No | ❌ No | ✅ Yes |

MBS( "CNContact.SetValue"; ContactIdentifier; Selector { ; Value } ) 

**MBS**( **"CNContact.SetValue";** /\* Sets the value of a contact. \*/  
**$ContactIdentifier**; /\* The contact identifier.e.g. "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" \*/   
**$Selector**; /\* Which value to set.e.g. "givenName" \*/   
**$Value**) /\* Optional; The value to set.e.g. "Test" \*/ 

### Parameters

| 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 |

### Result

Returns OK or error.

### Description

Sets the value of a contact.  
Selector can be birthday, contactRelations, dates, departmentName, emailAddresses, familyName, givenName, imageData, imageDataAvailable, instantMessageAddresses, jobTitle, middleName, namePrefix, nameSuffix, nickname, nonGregorianBirthday, organizationName, phoneNumbers, phoneticFamilyName, phoneticGivenName, phoneticMiddleName, phoneticOrganizationName, postalAddresses, previousFamilyName, socialProfiles, thumbnailImageData, note, type or urlAddresses.  
ImageData and thumbnailImageData are passed as containers.  
PhoneNumbers, emailAddresses, postalAddresses, urlAddresses, contactRelations, socialProfiles, instantMessageAddresses, dates, birthday and nonGregorianBirthday are passed as JSON.  
  
See also Apple's documentation:  
<https://developer.apple.com/documentation/contacts/cncontact>  
  
For iOS 13 or later or macOS 16 or later, the note property can't be set or read unless the application has permissions for that and FileMaker Pro doesn't have these. AppleScript may work around this.  
### Examples

Set given name fo ra contact:

 Set Variable \[ $r ; Value: MBS ( "CNContact.SetValue"; $contactID ; "givenName"; "Joe" ) \]  
Clear email for contact:

 MBS ( "CNContact.SetValue"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson"; "emailAddresses"; "\[\]") &amp;  
// first set email list to empty JSON array and save  
MBS ( "[CNContactStore.UpdateContact](CNContactStoreUpdateContact.md)"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson" )  
Set email list with two emails:

 MBS ( "[CNContact.Value](CNContactValue.md)"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson"; "emailAddresses"; "\[{ \\"label\\" : \\"\_$!&lt;Home&gt;!$\_ \\", \\"value\\" : \\"home@test.de\\" }, { \\"label\\" : \\"My Label\\", \\"value\\" : \\"private@test.de\\" } \]") &amp;  
// and save  
MBS ( "[CNContactStore.UpdateContact](CNContactStoreUpdateContact.md)"; "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](component_AppleScript.md) 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](AppleScriptCompile.md)"; "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](AppleScriptLastError.md)" ) &amp; ¶ &amp; MBS ( "[AppleScript.LastErrorMessage](AppleScriptLastErrorMessage.md)" ) \]   
\# run a query or multiple   
Set Variable \[ $r ; Value: MBS ( "[AppleScript.SetPropertyValue](AppleScriptSetPropertyValue.md)"; $ScriptID ; "theID"; $theID ) \]   
Set Variable \[ $r ; Value: MBS ( "[AppleScript.SetPropertyValue](AppleScriptSetPropertyValue.md)"; $ScriptID ; "theNote"; $theNote ) \]   
Set Variable \[ $result ; Value: MBS ( "[AppleScript.Execute](AppleScriptExecute.md)"; $ScriptID ) \]   
Show Custom Dialog \[ "Result from AppleScript" ; $result &amp; ¶ &amp; MBS ( "[AppleScript.LastError](AppleScriptLastError.md)" ) &amp; ¶ &amp; MBS ( "[AppleScript.LastErrorMessage](AppleScriptLastErrorMessage.md)" ) \]   
\# free memory   
Set Variable \[ $r ; Value: MBS ( "[AppleScript.Close](AppleScriptClose.md)"; $ScriptID ) \]  
### See also

- [AppleScript.Close](AppleScriptClose.md)
- [AppleScript.Compile](AppleScriptCompile.md)
- [AppleScript.LastError](AppleScriptLastError.md)
- [AppleScript.SetPropertyValue](AppleScriptSetPropertyValue.md)
- [CNContact.AddInstantMessage](CNContactAddInstantMessage.md)
- [CNContact.AddPhoneNumber](CNContactAddPhoneNumber.md)
- [CNContact.HasValue](CNContactHasValue.md)
- [CNContact.Value](CNContactValue.md)
- [CNContactStore.AddContact](CNContactStoreAddContact.md)
- [CNContactStore.NewContact](CNContactStoreNewContact.md)

### Release notes

- **Version 10.2**
    - Fixed [CNContact.SetValue](https://www.mbsplugins.eu/CNContactSetValue.shtml) and related to accept numbers for date component values, e.g. to set birthday.

### Example Databases

- [Mac and iOS/Contacts/Contacts](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Mac%20and%20iOS/Contacts/Contacts.shtml#7ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Advent calendar - Door 5 - Apple Contacts](https://www.mbsplugins.de/archive/2024-12-05/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 10.2pr7](https://www.mbsplugins.de/archive/2020-05-07/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 8.4pr4](https://www.mbsplugins.de/archive/2018-08-21/MBS_FileMaker_Plugin_version_8/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 1st August 2018 , last changed 25th February 2026

  
[CNContact.Name](CNContactName.md) - [CNContact.Show](CNContactShow.md)

[HTML Version](CNContactSetValue.shtml)