ContactOrganization

Contains organization properties of a [Contact](../Contact/contact.html) object.

Properties

  • pref: Set to true if this ContactOrganization contains the user's preferred value. (boolean)
  • type: A string that tells you what type of field this is (example: 'home'). _(DOMString)
  • name: The name of the organization. (DOMString)
  • department: The department the contract works for. (DOMString)
  • title: The contacts title at the organization. (DOMString)

Details

The ContactOrganization object stores a contact's organization properties. A [Contact](../Contact/contact.html) object stores one or more ContactOrganization objects in an array.

Supported Platforms

  • Android
  • BlackBerry WebWorks (OS 5.0 and higher)
  • iOS

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-1.6.1.js"></script>
    <script type="text/javascript" charset="utf-8">

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

    // Cordova is ready
    //
    function onDeviceReady() {
		var options = new [ContactFindOptions](../ContactFindOptions/contactfindoptions.html)();
		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: This property is not supported by Android 2.X devices and will always return false.

Android 1.X Quirks

  • pref: This property is not supported by Android 1.X devices and will always return false.
  • type: This property is not supported by Android 1.X devices and will always return null.
  • title: This property is not supported by Android 1.X devices, and will always be returned as null.

BlackBerry WebWorks (OS 5.0 and higher) Quirks

  • pref: This property is not supported by BlackBerry devices and will always return false.
  • type: This property is not supported by BlackBerry devices and will always return null.
  • name: Partially supported. The first organization name will be stored in the BlackBerry company field.
  • department: This property is not supported, and will always be returned as null.
  • title: Partially supported. The first organization title will be stored in the BlackBerry jobTitle field.

iOS Quirks

  • pref: This property is not supported on iOS devices and will always return false.
  • type: This property is not supported on iOS devices and will always return null.
  • name: Partially supported. The first organization name will be stored in the iOS kABPersonOrganizationProperty field.
  • department: Partially supported. The first department name will be stored in the iOS kABPersonDepartmentProperty field.
  • title: Partially supported. The first title will be stored in the iOS kABPersonJobTitleProperty field.