license: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

     Unless required by applicable law or agreed to in writing,
     software distributed under the License is distributed on an
     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     KIND, either express or implied.  See the License for the
     specific language governing permissions and limitations
     under the License.

ContactOrganization

Contains a Contact object's organization properties.

Properties

  • pref: Set to true if this ContactOrganization contains the user's preferred value. (boolean)

  • type: A string that indicates what type of field this is, home for example. _(DOMString)

  • name: The name of the organization. (DOMString)

  • department: The department the contract works for. (DOMString)

  • title: The contact's title at the organization. (DOMString)

Details

The ContactOrganization object stores a contact's organization properties. A Contact object stores one or more ContactOrganization objects in an array.

Supported Platforms

  • Android
  • BlackBerry 10
  • iOS
  • Windows Phone 7 and 8
  • Windows 8

Quick Example

function onSuccess(contacts) {
    for (var i = 0; i < contacts.length; i++) {
        for (var j = 0; j < contacts[i].organizations.length; j++) {
            alert("Pref: "      + contacts[i].organizations[j].pref       + "\n" +
                "Type: "        + contacts[i].organizations[j].type       + "\n" +
                "Name: "        + contacts[i].organizations[j].name       + "\n" +
                "Department: "  + contacts[i].organizations[j].department + "\n" +
                "Title: "       + contacts[i].organizations[j].title);
        }
    }
};

function onError(contactError) {
    alert('onError!');
};

var options = new ContactFindOptions();
options.filter = "";
filter = ["displayName", "organizations"];
navigator.contacts.find(filter, onSuccess, onError, options);

Full Example

<!DOCTYPE html>
<html>
  <head>
    <title>Contact Example</title>

    <script type="text/javascript" charset="utf-8" src="cordova.js"></script>
    <script type="text/javascript" charset="utf-8">

    // Wait for device API libraries to load
    //
    document.addEventListener("deviceready", onDeviceReady, false);

    // device APIs are available
    //
    function onDeviceReady() {
        var options = new ContactFindOptions();
        options.filter="";
        filter = ["displayName","organizations"];
        navigator.contacts.find(filter, onSuccess, onError, options);
    }

    // onSuccess: Get a snapshot of the current contacts
    //
    function onSuccess(contacts) {
        for (var i = 0; i < contacts.length; i++) {
            for (var j = 0; j < contacts[i].organizations.length; j++) {
                alert("Pref: "     + contacts[i].organizations[j].pref       + "\n" +
                    "Type: "       + contacts[i].organizations[j].type       + "\n" +
                    "Name: "       + contacts[i].organizations[j].name       + "\n" +
                    "Department: " + contacts[i].organizations[j].department + "\n" +
                    "Title: "      + contacts[i].organizations[j].title);
            }
        }
    };

    // onError: Failed to get the contacts
    //
    function onError(contactError) {
        alert('onError!');
    }

    </script>
  </head>
  <body>
    <h1>Example</h1>
    <p>Find Contacts</p>
  </body>
</html>

Android 2.X Quirks

  • pref: Not supported by Android 2.X devices, returning false.

BlackBerry 10 Quirks

  • pref: Not supported by BlackBerry devices, returning false.

  • type: Not supported by BlackBerry devices, returning null.

  • name: Partially supported. The first organization name is stored in the BlackBerry company field.

  • department: Not supported, returning null.

  • title: Partially supported. The first organization title is stored in the BlackBerry jobTitle field.

iOS Quirks

  • pref: Not supported on iOS devices, returning false.

  • type: Not supported on iOS devices, returning null.

  • name: Partially supported. The first organization name is stored in the iOS kABPersonOrganizationProperty field.

  • department: Partially supported. The first department name is stored in the iOS kABPersonDepartmentProperty field.

  • title: Partially supported. The first title is stored in the iOS kABPersonJobTitleProperty field.