Topics   All   MacOS (Only)   Windows (Only)   Linux (Only, Not)   iOS (Only, Not)  
Components   Crossplatform Mac & Win   Server   Client   Old   Deprecated   Guides   Examples   Videos
New in version: 12.2   12.3   12.4   12.5   13.0   13.1   13.2   13.3   13.4   13.5    Statistic    FMM    Blog  

CNContact.SetValue

Sets the value of a contact.

Component Version macOS Windows Linux Server iOS SDK
Contacts 8.4 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "CNContact.SetValue"; ContactIdentifier; Selector { ; Value } )   More

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.

Examples

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

See also

Release notes

Example Databases

Blog Entries

This function checks for a license.

Created 1st August 2018, last changed 27th February 2023


CNContact.Name - CNContact.Show

💬 Ask a question or report a problem