Returns a new contact object. Various properties like name, phone, address etc. can be set using the helper methods provided on the contact object. Use $m.saveContact() or $m.contact.save() method to save a contact.
var contactObj = $m.contact("Mowbly Support", "0999999999", "support@mowbly.com" ); |
The contact object does not hold any reference to a contact in the native address book until it is saved.
Syntax
$m.contact()
$m.contact([name, phoneNumber, email])
Parameters
name
string (optional)
The name of the contact.
phoneNum
string/number (optional)
The phone number of the contact.
string (optional)
The email address of the contact.
Returns
Contact {object}. Object that contains the following methods,
save
Saves the specified contact to the native contacts.
contactObj.save(function(response){ if(response.code){ $m.toast("contact saved"); } else { $m.toast(r.error.message); } }); |
Syntax
save(fp_callback)
Parameters
fp_callback
function (optional)
The function that gets invoked when the save operation is completed. The function receives a response object as parameter with the following properties,
- code - {Number}. The value can be 0 or 1. 1 indicates that the save operation is successful. 0 indicates a failure.
- result - {Array}. Contact object passed. If the save operation is successful, then the contact object will have an id property that is the unique identifier of the contact in the native contacts list.
- error - {Object}. Available when the code is 0. The error object contains,
- message - {String}. A short description of the error.
- description - {String}. A detailed description of the error.
Remarks
This method always creates new contact. Update of existing contact is not supported in the current version of the framework.
view
Launches the native contact viewer to display the properties of the specified contact.
contactObj.view() |
Syntax
view()
Remarks
In Windows Phone 7, native contact viewer is not exposed for external applications. So Mowbly framework’s native contact viewer will display.
remove
Deletes the specified contact from the native contacts list.
contactObj.remove(function(){ if(response.code){ $m.toast("contact removed"); } else { $m.toast(r.error.message); } }) |
Syntax
remove(fp_callback)
Parameters
fp_callback
function (optional)
The function to execute when the remove operation is completed. The function receives a response object as parameter with the following properties,
- code - {Number}. The value can be 0 or 1. 1 indicates that the save operation is successful. 0 indicates a failure.
- result - {Array}. Contact object passed. If the save operation is successful, then the contact object will have an id property that is the unique identifier of the contact in the native contacts list.
- error - {Object}. Available when the code is 0. The error object contains,
- message - {String}. A short description of the error.
- description - {String}. A detailed description of the error.
Name
getName
Returns the name of the contact.
var name = contactObj.getName(); |
Syntax
getName()
Return value
- Name - {Object}. The name object with the following properties,
- firstName - {String}. First name of the contact.
- lastName - {String}. Last name of the contact.
- middleName - {String}. Middle name of the contact.
- prefix - {String}. Prefix of the contact.
- suffix - {String}. Suffix of the contact.
setName
Sets the name of the contact.
contactObj.setName("cloudpact", "Mowbly") |
Syntax
setName(firstName, lastName, middleName, prefix, suffix)
Parameters
firstName
string (required)
First name of the contact.
lastName
string (optional)
Last name of the contact.
middleName
string (optional)
Middle name of the contact.
prefix
string (optional)
Prefix of the contact.
suffix
string (optional)
Suffix of the contact.
Return value
- contact - {Contact}. Contact object.
phone
getPhone
Returns the phone number of the contact for the specified type.
var workPhone = contactObj.getPhone("work"); |
Syntax
getPhone(type)
Parameters
type
string (optional)
Type of the phone. Possible values are ‘work’, ‘home’, ‘mobile’, ‘other’ and ‘fax’.
Return value
- Phone number - {String}. The specified type of phone number of the contact, if type is provided; the available phone number in types ‘work’, ‘home’, ‘mobile’, ‘other’ or ‘fax’ otherwise.
getPhones
Returns the available phone numbers in the contact indexed by type.
var phones = contactObj.getPhones(); |
Syntax
getPhones()
Return value
- Phones - {Object}. Object containing none or many of the following properties,
- work - {String}. Work phone number of the contact.
- home - {String}. Home phone number of the contact.
- other - {String}. Other phone number of the contact.
- mobile - {String}. Mobile phone number of the contact.
- fax - {String}. Fax number of the contact.
- pager - {String}. Pager number of the contact.
setPhone
Sets the specified type of phone number of the contact, if type is provided otherwise sets the work type phone number .
contactObj.setPhone(9090909090,"home"); |
Syntax
setPhone(phoneNumber [, type])
Parameters
phoneNumber
string/number (required)
Phone number of the contact.
type
string (optional)
Type of the phone number. Possible values are ‘work’, ‘home’, ‘’mobile, ‘other’ and ‘fax’. Default value is ‘work’.
Return value
- contact - {Contact}. Contact object.
getEmail
Returns the specified type email of the contact, if type is provided otherwise returns the work type email.
var workEmail = contactObj.getEmail("work"); |
Syntax
getEmail(type)
Parameters
type
string (optional)
Type of the email. Possible values are ‘work’, ‘home’, ‘mobile’ and ‘other’.
Return value
- Email - {String}. The specified type of emai of the contact, if type is provided; the available email in types ‘work’, ‘home’ or ‘other’ otherwise.
getEmails
Returns the available emails in the contact indexed by type.
var emails = contactObj.getEmails(); |
Syntax
getEmails()
Return value
- emails - {Object}. Object containing none or many of the following properties,
- work - {String}. Work email of the contact.
- home - {String}. Home email of the contact.
- other - {String}. Other email of the contact.
setEmail
Sets the specified type of email of the contact, if type is provided otherwise sets the work email.
contactObj.setEamil("mowbly@support.com","home"); |
Syntax
setEmail(emailt [,type])
Parameters
string (required)
Email of the contact.
type
string (optional)
Type of the email. Possible values are ‘work’, ‘home’ and ‘other’.
Return value
- contact - {Contact}. Contact object.
Address
getAddress
Returns the specified type of address of the contact of type provided.
var workAddress = contactObj.getAddress("work"); |
Syntax
getAddress(type)
Parameters
type
string (optional)
Type of the address. Possible values are ‘work’, ‘home’ and ‘other’.
Return value
Address - {Object}. The specified type of address of the contact, if type is provided; the available address in types ‘work’, ‘home’ or ‘other’ otherwise. The address object would contain one or more of the following properties,
- street - {String}. Street name.
- city - {String}. City name.
- region - {String}. Region name.
- postalCode - {String/Number}. Postal code of the address.
getAddresses
Returns the available addresses in the contact indexed by type.
var addresses = contactObj.getAddresses(); |
Syntax
getAddresses()
Return value
- addresses - {Object}. Object containing none or many of the following properties,
- work - {String}. Work address of the contact.
- home - {String}. Home address of the contact.
- other - {String}. Other address of the contact.
setAddress
Sets the specified type of address of the contact, if type is provided otherwise sets the work address.
contactObj.setAddress({"street":"madhapoor","city":"Hyderabad","region":"asia", "postalCode":"500001"},"work"); |
Syntax
setAddress(address, type)
Parameters
address
object (required)
Object containing none or many of the following properties,
- street - {Optional. String}. Street name.
- city - {Optional. String}. City name.
- region - {Optional. String}. Region name.
- postalCode - {Optional. String/Number}. Postal code of the address.
type
string (optional)
Type of the address. Possible values are ‘work’, ‘home’ and ‘other’.
Return value
- contact - {Contact}. Contact object.
Url
getUrl
Returns the specified type of url of the contact for the type provided.
var workUrl = contactObj.getUrl("work"); |
Syntax
getUrl(type)
type
string (optional)
Type of the url. Possible values are ‘work’, ‘home’ and ‘other’.
Return value
- Url - {string}. The specified type of url of the contact, if type is provided; the available url in types ‘work’, ‘home’ or ‘other’ otherwise.
getUrls
Returns the available urls in the contact by type.
var urls = contactObj.getUrls(); |
Syntax
getUrls()
Return value
- urls - {Object}. Object containing none or many of the following properties,
- work - {String}. Work url of the contact.
- home - {String}. Home url of the contact.
- other - {String}. Other url of the contact.
setUrl
Sets the specified type of url of the contact, if type is provided otherwise sets work url.
contactObj.setUrls("www.cloudpact.com","work"); |
Syntax
setUrl(url, type)
Parameters
url
string (required)
Url of the contact.
type
string (optional)
Type of the url. Possible values are ‘work’, ‘home’ and ‘other’.
Return value
- contact - {Contact}. Contact object.
Organization
getOrganization
Returns the organization of the contact.
var organization = contactObj.getOrganization(); |
Syntax
getOrganization()
Return value
- Organization - {Object}. The organization object with the following properties,
- Organization name - {String}. Name of the organization of the contact.
- Job title - {String}. Job title of the contact.
- Department -{String}. Department name of the contact.
setOrganization
Sets the organization of the contact.
contactObj.setOrganization("cloudpact","SE", "10"); |
Syntax
setOrganization(oganizationName, jobTitle, department)
Parameters
organizationName
string (optional)
Name of the organization of the contact.
jobTitle
string (optional)
Job title of the contact.
department
string (optional)
Department name of the contact.
Return value
- contact - {Contact}. Contact object.
Note
getNote
Returns any notes (additional information) stored for this contact.
var note = contactObj.getNote(); |
Syntax
getNote()
Return value
- note - {String}. Note stored for this contact.
setNote
Sets the notes (additional information) for this contact.
contactObj.setNote("mowbly webinar on 15/Dec/2012"); |
Syntax
setNote(note)
Parameters
note
string (optional)
The note content for the contact.
Return value
- contact - {Contact}. Contact object.
Birthday
getBirthday
Returns the birthday
var birthday = contactObj.getBirthday(); |
Syntax
getBirthday()
Return value
- Birthday - {String}. Birthday of the contact in format MM/DD/YYYY.
setBirthday
Sets the birthday of the contact.
contactObj.setBirthday("08/28/1989"); |
Syntax
setBirthday(birthday)
Parameters
birthday
string (optional)
Birthday of the contact. Supported format is MM/DD/YYYY.
Return value
- contact - {Contact}. Contact object.