CNContactStore.NewContact
-------------------------

Creates new empty contact.

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

MBS( "CNContactStore.NewContact" ) ### Parameters

none

### Result

Returns contact identifier or error.

### Description

Creates new empty contact.  
Please use later [CNContactStore.AddContact](CNContactStoreAddContact.md) to store changes.  
### Examples

Create a contact:

 Set Variable \[ $contactID ; Value: MBS ( "CNContactStore.NewContact") \]   
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](CNContactAddPhoneNumber.md)"; $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.AddRelation](CNContactAddRelation.md)
- [CNContact.AddSocialProfile](CNContactAddSocialProfile.md)
- [CNContact.AddURLAddress](CNContactAddURLAddress.md)
- [CNContactStore.AddContact](CNContactStoreAddContact.md)
- [CNContactStore.Contacts](CNContactStoreContacts.md)
- [CNContactStore.DeleteContact](CNContactStoreDeleteContact.md)
- [CNContactStore.UpdateContact](CNContactStoreUpdateContact.md)
- [Container.ReadFile](ContainerReadFile.md)
- [JSON.Colorize](JSONColorize.md)
- [JSON.Format](JSONFormat.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)

This function checks for a license.

Created 2nd August 2018 , last changed 6th August 2018

  
[CNContactStore.GroupsInContainer](CNContactStoreGroupsInContainer.md) - [CNContactStore.RemoveMember](CNContactStoreRemoveMember.md)

[HTML Version](CNContactStoreNewContact.shtml)