CNContact.Value
---------------

Queries the value of contact.

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

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

**MBS**( **"CNContact.Value";** /\* Queries the value of contact. \*/  
**$ContactIdentifier**; /\* The contact identifier.e.g. "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" \*/   
**$Selector**; /\* Which value to return.e.g. "nickname" \*/   
**$ImageType**; /\* Optional; The type of image to return.   
Either JPEG, PNG, GIF or BMP. Default is JPEG.e.g. "JPEG" \*/   
**$FileName**) /\* Optional; The filename to use for the picture.   
Default is "image" with the extension matching the image type.e.g. "test.jpg" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ContactIdentifier | The contact identifier. | "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" |  |
| Selector | Which value to return. | "nickname" |  |
| ImageType | The type of image to return.    Either JPEG, PNG, GIF or BMP. Default is JPEG. | "JPEG" | Optional |
| FileName | The filename to use for the picture.    Default is "image" with the extension matching the image type. | "test.jpg" | Optional |

### Result

Returns value or error.

### Description

Queries the value of 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 returned as container and you can pass in ImageType and FileName to use.  
PhoneNumbers, emailAddresses, postalAddresses, urlAddresses, contactRelations, socialProfiles, instantMessageAddresses, dates, birthday and nonGregorianBirthday are returned as JSON.  
  
See also Apple's documentation:  
<https://developer.apple.com/documentation/contacts/cncontact>  
### Examples

Get my phone numbers:

 MBS ("CNContact.Value"; MBS ("[CNContactStore.UnifiedMeContact](CNContactStoreUnifiedMeContact.md)"); "phonenumbers")  
<small>  
Example result:   
\[ { "identifier" : "7AA474C5-CB5B-406F-9C19-077E14E8F48B" , "label" : "\_$!&lt;Mobile&gt;!$\_" , "value" : "+49 1234 56789" }, { "identifier" : "96F71635-B932-49C5-ABA6-905528A152D0" , "label" : "\_$!&lt;Work&gt;!$\_" , "value" : "+49 1234 56789" } \] </small>Get my social profiles:

 MBS ("CNContact.Value"; MBS ("[CNContactStore.UnifiedMeContact](CNContactStoreUnifiedMeContact.md)"); "socialprofiles")  
<small>  
Example result:   
\[ { "identifier" : "DC992125-7999-4C52-ADF6-D544BC3ADA04" , "label" : "Twitter" , "value" : { "username" : "MBSPlugins" , "userIdentifier" : null, "service" : "Twitter" , "urlString" : "http:\\/\\/twitter.com\\/MBSPlugins" } }, { "identifier" : "4D26EDF7-EE68-4125-AAF1-C79C5D4A66AA" , "label" : "Facebook" , "value" : { "username" : "MonkeybreadSoftware" , "userIdentifier" : null, "service" : "Facebook" , "urlString" : "http:\\/\\/facebook.com\\/MonkeybreadSoftware" } } \] </small>Get image of contact as container value:

 MBS ( "CNContact.Value"; $contact ; "imageData")  
Query email addresses:

 MBS ( "CNContact.Value"; "BD2307E5-92F6-4A8F-946D-C4804615C18B:ABPerson"; "emailAddresses")  
Get type of contact:

 MBS ( "CNContact.Value"; $contact ; "type")  
<small>  
Example result: Returns "Organization" or "Person"</small>Query contacts app for Note for a contact:

 # Read Contact Note via AppleScript   
Set Variable \[ $theID ; Value: "773E1A42-ABCD-4CCF-88DE-E9C64BEE6D33:ABPerson" \]   
\# Compile AppleScript   
Set Variable \[ $ScriptID ; Value: MBS ( "[AppleScript.Compile](AppleScriptCompile.md)"; "property theID : \\"\\"¶ tell application \\"Contacts\\"¶ set theContact to the first person whose id is theID¶ return note of theContact¶ end tell" ) \]   
\# run a query or multiple   
Set Variable \[ $r ; Value: MBS ( "[AppleScript.SetPropertyValue](AppleScriptSetPropertyValue.md)"; $ScriptID ; "theID"; $theID ) \]   
Set Variable \[ $result ; Value: MBS ( "[AppleScript.Execute](AppleScriptExecute.md)"; $ScriptID ) \]   
Show Custom Dialog \[ "Result from AppleScript" ; $result \]   
\# free memory   
Set Variable \[ $r ; Value: MBS ( "[AppleScript.Close](AppleScriptClose.md)"; $ScriptID ) \]  
### See also

- [AppleScript.Close](AppleScriptClose.md)
- [AppleScript.Compile](AppleScriptCompile.md)
- [AppleScript.Execute](AppleScriptExecute.md)
- [AppleScript.SetPropertyValue](AppleScriptSetPropertyValue.md)
- [CNContact.HasValue](CNContactHasValue.md)
- [CNContact.Name](CNContactName.md)
- [CNContact.SetValue](CNContactSetValue.md)
- [CNContactPicker.Current](CNContactPickerCurrent.md)
- [CNContactStore.FetchContact](CNContactStoreFetchContact.md)
- [CNContactStore.UnifiedMeContact](CNContactStoreUnifiedMeContact.md)

### Release notes

- **Version 15.1**
    - Fixed [CNContact.Value](https://www.mbsplugins.eu/CNContactValue.shtml) function to return empty value for birthday if there is none, instead of an error.

### Example Databases

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

### Blog Entries

- [MBS FileMaker Plugin, version 15.1pr1](https://www.mbsplugins.de/archive/2025-02-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Advent calendar - Door 5 - Apple Contacts](https://www.mbsplugins.de/archive/2024-12-05/MBS_FileMaker_Advent_calendar_/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 12.1](https://www.mbsplugins.de/archive/2022-03-22/New_in_MBS_FileMaker_Plugin_12/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 17th November 2023

  
[CNContact.UnifiedContacts](CNContactUnifiedContacts.md) - [CNContactPicker.Close](CNContactPickerClose.md)

[HTML Version](CNContactValue.shtml)