Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

CNContactStore.AddContact

Adds a new contact to the database.

Component Version macOS Windows Linux Server iOS SDK
Contacts 8.4 ✅ Yes ❌ No ❌ No ❌ No ✅ Yes
MBS( "CNContactStore.AddContact"; ContactIdentifier { ; ContainerIdentifier } )   More

Parameters

Parameter Description Example Flags
ContactIdentifier The contact identifier. "46B1E34D-58F9-4B6B-A80D-0F71ABB87A0E"
ContainerIdentifier The identifier for the container. "9892A5CC-964E-497A-B877-A47619F7493C:ABAccount" Optional

Result

Returns OK or error.

Description

Adds a new contact to the database.
Optionally pass in container identifier to specify which account to use.

Examples

Create a contact:

#
Set Variable [ $contactID ; Value: MBS( "CNContactStore.NewContact") ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "givenName"; "Joe" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "familyName"; "Miller" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "jobTitle"; "Family Manager" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "organization"; "Family" ) ]
#
#
Set Variable [ $image ; Value: MBS( "Container.ReadFile"; "/Library/Desktop Pictures/Lion.jpg") ]
Set Variable [ $r ; Value: MBS( "CNContact.SetValue"; $contactID; "imageData"; $image ) ]
#
Set Variable [ $r ; Value: MBS( "CNContact.AddEmailAddress"; $contactID; "test@test.test"; "Work" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddInstantMessage"; $contactID; "instantTest"; "Facebook"; "Work" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddURLAddress"; $contactID; "http://www.monkeybreadsoftware.com/"; "Homepage" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddSocialProfile"; $contactID; "Home"; "http://www.facebook.com"; "testSocial"; ""; "Facebook" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddRelation"; $contactID; "Jane Miller"; "Sister" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddPhoneNumber"; $contactID; "123 456 789"; "iPhone" ) ]
Set Variable [ $r ; Value: MBS( "CNContact.AddPostalAddress"; $contactID; "Home"; "Main Street 123"; "New City"; "NS"; "12345"; "USA"; "US" ) ]
#
Set Variable [ $contactID ; Value: MBS( "CNContactStore.AddContact"; $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"; $contactID) ]
    Set Variable [ $json ; Value: MBS("JSON.Colorize"; MBS( "JSON.Format"; $json) ) ]
    Set Field [ Contacts::Result ; $json ]
End If

See also

Example Databases

This function checks for a license.

Created 1st August 2018, last changed 6th August 2018


CNContactPicker.Show - CNContactStore.AddGroup

💬 Ask a question or report a problem