BlackBerry
Skip Top Navigation
Developers Partners
North America [change region] Products Solutions Purchasing Support
Developers


Retrieve a Subset of Contacts on a BlackBerry Device

Exercise

Retrieve a subset of contacts on a BlackBerry® device by designing a screen with choice control with an initial value property set to a subset of contacts. The WHERE clause determines a subset of contacts (for example, WHERE nameFamily=@gv_Name). In this example, contacts that have the field nameFamily equal to the global variable string gv_Name display in the choice control. The screen maps the choice control to a local variable, contact, of type Contact. Use similar screens and constructs for the keyed built-in data components to display subsets of these data collections.

Objectives

  • Discover how to retrieve a subset of contacts on a BlackBerry device.

Setup Tasks

Create an application that can access the local address book. See the lab entitled Create a Contact Using the Top-Down Approach for more details.

Open BlackBerry MDS Studio™ and select the Contact Viewer project which you created in the previous lab. See the lab entitled Create a Contact Using the Top-Down Approach and Display Contact Information for more details.

If you have not completed the first two labs in this series, create the Contact Viewer project following these steps:

  1. Download the Contact Viewer workspace (ZIP) and unzip the file.
  2. Import the Contact Viewer workspace to BlackBerry MDS Studio
    Click File menu -> Import Existing… -> Browse -> select Contact Viewer -> Finish

Tasks

Create a global variable

  1. In the Navigator pane, expand Data.
  2. Right-click Globals.
  3. Click New Global.
  4. In the Name field, type a name, for example, gv_name.
  5. Click Finish.

Create a contact screen with a contact local variable

  1. In the Navigator pane, create a new screen (i.e. scrSubContact).
  2. In the Screen Editor, click on the screen canvas.
  3. In the Properties pane, in the Local Variables property, click ....
  4. Click +.
  5. In the Name cell, type contact.
  6. In the Type drop-down list, click Contact.
  7. Click OK.

Note: You can now assign screen controls to the screen local variable contact, which is an instance of the built-in data component Contact.

Create the contact list lookup field

  1. Create a choice control.
  2. In the list of available data, expand Collections > Built-in > Contact.
  3. Click nameFamily.
  4. Click Apply.
  5. In the expression field, click in the brackets of the expression @Contact[].nameFamily.
  6. In the Field drop-down list, click nameFamily.
  7. In the Operator drop-down list, click =.
  8. Perform one of the following actions:
Action Procedure
Assign a static value.
  1. In the Value field, type a value.
  2. Click Apply.
Assign a dynamic value.
  1. In the list of available data, expand Globals.
  2. Click the global variable that you created previously, for examply, gv_Name.
  3. Click Apply.

  1. Click OK.
  2. In the Properties pane, in the Mapping property, click ....
  3. Expand Local Variables.
  4. In the list of available data, click contact.
  5. Click OK.

Create the contact list lookup field

Additional Labs

Back to the Developer Lab Main Menu

 
Other Resources
 
     
 Home | Products | Solutions | Purchasing | Support | Developers | Worldwide | News | About Us | Contact Us | Site Map
 Legal | Copyright © 2008 Research In Motion Limited, unless otherwise noted.