Skip to main content

Custom Name Picker

In this tutorial you will learn how to use the Name Picker extension type.

Add the Extension

[
{
"name": "Custom Name Picker",
"title": "Custom Name Picker",
"description": "Sample that shows how to add a custom name picker in mail compose view",
"extensions": [
{
"type": "com.ibm.verse.ext.namePicker",
"name": "Custom name picker in mail compose",
"payload": {
"url": "${extensionPath}/custom-name-picker/index.html"
}
}
],
"services": [
"Verse"
]
}
]

Extension Properties

PropertyTypeDefinition
namestringthe name of the extension
typestringthe extension point (List of Extension Points)
payloadobjectJSON object that specifies properties specific to the extension
urlstringThe fully-qualified URL of your application

Test it Out

How it Works

This extension turns the To field, in the Mail Compose view into a link. Selecting the To field opens an embedded web application specified in the url property. In this example, the web application is custom-name-picker/index.html which renders a list of sample users that are defined in custom-name-picker/ui.js.

When the To link is selected, Verse sends a message to the web application with the verseApiType com.ibm.verse.ping.application.loaded. When the application has loaded, it solidifies the handshake by sending back a message with verseApiType com.ibm.verse.application.loaded. Now that Verse knows the application is ready to receive data, the extension recieves a new message from Verse with the verseApiType com.ibm.verse.action.clicked. It is also good practice to verify the actionId which, for the Name Picker extension, is com.ibm.verse.ext.action.namePicker.

Each sample user in the custom name picker has an Add button that posts a message back to Verse with the verseApiType com.ibm.verse.add.contact and the data of the selected user. Verse uses that data to add the user's name to the To field.

The custom name picker application in this tutorial only supports adding single users at a time to the To field. Please reference the Name Picker extension point for information on adding multiple users at a time and how to add users to the Cc and Bcc fields.