CNContact.AddPhoneNumber
------------------------

Adds an phone number to 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.AddPhoneNumber"; ContactIdentifier; PhoneNumber { ; Label } ) 

**MBS**( **"CNContact.AddPhoneNumber";** /\* Adds an phone number to a contact. \*/  
**$ContactIdentifier**; /\* The contact identifier.e.g. "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" \*/   
**$PhoneNumber**; /\* The phone number.e.g. "+49123456" \*/   
**$Label**) /\* Optional; The label to use.  
For your convenience we translate Work, Home and Other to the right values, so they get localized in display.  
Default label is Other.e.g. "Work" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| ContactIdentifier | The contact identifier. | "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E" |  |
| PhoneNumber | The phone number. | "+49123456" |  |
| Label | The label to use.   For your convenience we translate Work, Home and Other to the right values, so they get localized in display.   Default label is Other. | "Work" | Optional |

### Result

Returns OK or error.

### Description

Adds an phone number to a contact.  
This is a convenience function to add just one phone number with a given label to the contact.  
Please call [CNContactStore.UpdateContact](CNContactStoreUpdateContact.md) later to store the values.  
### Examples

Create contact:

 Set Variable \[ $contactID ; Value: MBS ( "[CNContactStore.NewContact](CNContactStoreNewContact.md)") \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.SetValue](CNContactSetValue.md)"; $contactID ; "givenName"; "Joe" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.SetValue](CNContactSetValue.md)"; $contactID ; "familyName"; "Miller" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.SetValue](CNContactSetValue.md)"; $contactID ; "jobTitle"; "Family Manager" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.SetValue](CNContactSetValue.md)"; $contactID ; "organization"; "Family" ) \]   
\#   
\#   
Set Variable \[ $image ; Value: MBS ( "[Container.ReadFile](ContainerReadFile.md)"; "/Library/Desktop Pictures/Lion.jpg") \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.SetValue](CNContactSetValue.md)"; $contactID ; "imageData"; $image ) \]   
\#   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddEmailAddress](CNContactAddEmailAddress.md)"; $contactID ; "test@test.test"; "Work" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddInstantMessage](CNContactAddInstantMessage.md)"; $contactID ; "instantTest"; "Facebook"; "Work" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddURLAddress](CNContactAddURLAddress.md)"; $contactID ; "http://www.monkeybreadsoftware.com/"; "Homepage" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddSocialProfile](CNContactAddSocialProfile.md)"; $contactID ; "Home"; "http://www.facebook.com"; "testSocial"; ""; "Facebook" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddRelation](CNContactAddRelation.md)"; $contactID ; "Jane Miller"; "Sister" ) \]   
Set Variable \[ $r ; Value: MBS ( "CNContact.AddPhoneNumber"; $contactID ; "123 456 789"; "iPhone" ) \]   
Set Variable \[ $r ; Value: MBS ( "[CNContact.AddPostalAddress](CNContactAddPostalAddress.md)"; $contactID ; "Home"; "Main Street 123"; "New City"; "NS"; "12345"; "USA"; "US" ) \]   
\#   
Set Variable \[ $contactID ; Value: MBS ( "[CNContactStore.AddContact](CNContactStoreAddContact.md)"; $contactID ) \]   
If \[ MBS ("IsError") \]   
 Show Custom Dialog \[ "Failed to create a contact" ; $r \]   
Else  
 Set Field \[ Contacts::ContactID ; $contactID \]   
 Set Variable \[ $json ; Value: MBS ( "[CNContact.JSON](CNContactJSON.md)"; $contactID ) \]   
 Set Variable \[ $json ; Value: MBS ("[JSON.Colorize](JSONColorize.md)"; MBS ( "[JSON.Format](JSONFormat.md)"; $json ) ) \]   
 Set Field \[ Contacts::Result ; $json \]   
End If  
### See also

- [CNContact.AddEmailAddress](CNContactAddEmailAddress.md)
- [CNContact.AddPostalAddress](CNContactAddPostalAddress.md)
- [CNContact.AddSocialProfile](CNContactAddSocialProfile.md)
- [CNContact.AddURLAddress](CNContactAddURLAddress.md)
- [CNContact.JSON](CNContactJSON.md)
- [CNContact.SetValue](CNContactSetValue.md)
- [CNContactStore.AddContact](CNContactStoreAddContact.md)
- [CNContactStore.UpdateContact](CNContactStoreUpdateContact.md)
- [Container.ReadFile](ContainerReadFile.md)
- [JSON.Colorize](JSONColorize.md)

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

Created 1st August 2018 , last changed 13th January 2021

  
[CNContact.AddInstantMessageJSON](CNContactAddInstantMessageJSON.md) - [CNContact.AddPostalAddress](CNContactAddPostalAddress.md)

[HTML Version](CNContactAddPhoneNumber.shtml)