Choice Lists: 4D Back End Calls

Creating the List - DAX_Devhook_InstallChoiceList

First set up an empty Choice List for each desired field. Inside the project method called DAX_Devhook_InstallChoiceList, put a call to DAX_Dev_SetChoiceList() for each field. Here are the specific calls in this example:

At this point you would see Choice Lists for the five fields, but they would contain no data.

    Syntax: DAX_Dev_SetChoiceList(selectionName, fieldName, listName)

Populating the List - DAX_DevHook_ListContents

Your Choice List could just receive data as is from a pre-existing 4D list in the Toolbox. Or you can override that data, or create the data totally from scratch, inside the project method DAX_DevHook_ListContents. Then just associate the data to the list you created in DAX_Devhook_InstallChoiceList. In this example data is all created on the fly.

Let's look at sample code for just one of the five Choice Lists. First declare variables for the incoming parameters.

C_TEXT($1;$list_t)
C_POINTER($2;$listItems_p)

$list_t:=$1  ` name of the list the Front-end has requested
$listItems_p:=$2  ` pointer to the text array contents of the list we are going to return to the Front-end

Test for each list you are trying to intercept or create. Only "task_repeat" is examined in this example. We declare a fresh array rather than dereferencing the passed in pointer, since we are simply going to create some values for it here.

Case of

  : ($list_t="task_repeat")
    ARRAY TEXT($listItems_p->;10)

Now put whatever values you want in the array. Here it is hard-coded, but the values could be arrived at programmatically.

    $listItems_p->{1}:=""
    $listItems_p->{2}:="Every Tuesday"
    $listItems_p->{3}:="Every Monday and Wednesday"
    $listItems_p->{4}:="Every weekday"
    $listItems_p->{5}:="Every day"
    $listItems_p->{6}:="Every week"
    $listItems_p->{7}:="Every 2 weeks"
    $listItems_p->{8}:="Every month"
    $listItems_p->{9}:="Every 6 months"
    $listItems_p->{10}:="Every year"

And we are done!

  End case

The DAX_Devhook_InstallChoiceList method provides a very convenient way to populate data into Choice Lists.