How-to add a contact in from a canvas app - #ARCHIVED#

This content has been archived. It may no longer be relevant.  

Adding a contact from a canvas app to is perhaps not as straightforward as you would expect. Below, code is shown which adds a contact to

A connection to needs to be created before this code will work.

The ContactPostItem action is used to add a contact. The first parameter is the folder where you want to add the contact to. The second parameter is the “GivenName” of the contact. The third parameter is a table for “HomePhones”. This parameter can be empty where empty means: Table({Value: ""}).

The fourth and last parameter contains other contact properties. Some are straightforward and some must be added as a record (The “BusinessAddress” in the example below).

        City: "Hometown",
        CountryOrRegion: "The Netherlands",
        PostalCode: "9999 AA",
        Street: "Street 1",
        State: ""
            {Value: "0031 11 111 1111"},
            {Value: "0031 22 222 2222"}
            CompanyName: "Forms and Flows",
            Surname: "Bakker",
            DisplayName: "Rick Bakker",
            MobilePhone1: "0031 6 12345678",
            BusinessAddress: First(coll_Contact_Record)

I also noticed that does not use the property “DisplayName”. It shows the property “GivenName” followed by the property “Surname”. The Outlook desktop client does use the property “DisplayName”.

When adding an address, you need to add all properties even when some are empty like the “State” in the example.