Hello everyone

Today we are discussing four separate topics. Each of these topics are used to create and manage a new list object on our application.

  1. Table layout and design
  2. On Fetch Event
  3. Getting records from an external database
  4. Building a list object

If we look at the structure of the People table, we see they have created four phone fields with four labels and four extensions. In today’s world a person could and most likely has more than that. IE Home, Business, Cell, Skype and the list goes on. To continually add fields to our table to meet and ever growing need would be poor programing design and a waste of time. Instead we will create a relational table which will allow for an ever growing number of communication methods.

What I did was create a table called communication and added the following fields to it.

  1. Contact_ID                      Character            8
  2. Comm_Type                    Character          15
  3. Comm_Number              Character          14

This table will be used as a look up table for every conceivable phone type a contact could have. Next we create the list object and place it on our People form on the Contact Method page of our conditional object. We set a Global Watch variable called cdv in our autoexec script. Finally we add the following code to our On Fetch Event for our form.

ui_freeze(.t.)
Ph_List = table.external_record_content_GET("communication", "RTrim(Com_Number)+\" - \"+Rtrim(Com_Type)","Com_Type","Contact_ID = '" + CONTACT_ID.TEXT + "'")
if cdv =1 then
   cdv = 0
else if cdv = 0 then
    cdv = 1
end if 
People_cdc:vc_comm.Activate()
People_cdc:vc_comm.Refresh()
if var->rolShow = 1 then
    People_cdc:browse1.activate()
else
    People_cdc:pl_contact.activate()    
end if
ui_freeze(.f.)

We used the on fetch event because our new form has several methods for fetching records and no matter which the user chooses, the on fetch event fires running our code and building our list of contact numbers.

To see how it all comes together, watch our short video. Again, if you find this lesson helpful, please let us know.