Source code

Below, you can find the source code of the hook function generated for the task described above.

This file can be generated in a simple text editor like Notepad.

The file has got the name hook_dataset.jpl and has to be in the application directory of the d.3 server.

The left column in the table contains the line numbers. These are not part of the source code. They are only included to describe the source code.

###
# Modul zum Ermitteln einer Wertemenge in Abhängigkeit von DOK_DAT_FELD_1
###
call d3_server_api_error_log("Hook-Demo: Modul geladen", 1, 9)
proc BuildDataset(repos_id, user, doc_type_short, row_no)
{
  call d3_server_api_error_log("Hook-Demo: Modul aufgerufen", 1, 9)
  call d3_server_api_error_log("Hook-Demo: DOK_DAT_FELD_1 = :dok_dat_feld[1]", 1, 9)
  if (dok_dat_feld[1] = "Simply Save")
  {
    call d3_server_api_error_log("Hook-Demo: Simply Save", 1, 9)
  
    d3server_field_no_allowed  [1] = "" 
    d3server_value_char_allowed[1] = "File Storage Tool"
    d3server_date_1_array      [1] = ""
    d3server_value_num_allowed [1] = ""
    d3server_repos_id_allowed  [1] = repos_id
    d3server_field_no_allowed  [2] = "" 
    d3server_value_char_allowed[2] = "Screenshot Creator"
    d3server_date_1_array      [2] = ""
    d3server_value_num_allowed [2] = ""
    d3server_repos_id_allowed  [2] = repos_id
  }
  else if (dok_dat_feld[1] = "Total Sources")
  {
    call d3_server_api_error_log("Hook-Demo: Total Sources", 1, 9)
    d3server_field_no_allowed  [1] = "" 
    d3server_value_char_allowed[1] = "Total Sources Photo Editor"
    d3server_date_1_array      [1] = ""
    d3server_value_num_allowed [1] = ""
    d3server_repos_id_allowed  [1] = repos_id
    d3server_field_no_allowed  [2] = "" 
    d3server_value_char_allowed[2] = "Total Sources Video Editor"
    d3server_date_1_array      [2] = ""
    d3server_value_num_allowed [2] = ""
    d3server_repos_id_allowed  [2] = repos_id
  }
  return 0
}

Warning

Before developing your own hook functions you are urgently requested to attend a training at d.velop AG.

The lines 1-3 are comments and have no influence on the application behavior. Line 4 generates a log file entry in the logviewer. This row displays at program start of the d.3 server the entry “hook-demo: module loaded" in the logviewer. If you configured all settings correctly, then this entry should be displayed in the logviewer as soon as the d.3 server is started. In line 9, another logviewer entry is generated. The content of doc_field_1 will be displayed here. It is important to use the “:” before the name of the field. Otherwise the entry would display the text “doc_feld[1]” instead of the field content.

Now, in row 11 the content of doc_field_1 will be requested. In case of the term “Simply Save”, the rows 14 - 26 will be run through and in case of the term “Total Sources”, it will be the rows 30 - 44.

The command in line 15 has to be given for compatibility reasons. In row 16 the first entry of the dataset will be assigned. Because in our example we want to assign the dataset to a alphanumeric advanced properties, it is necessary to use the global list (array) d3server_value_char_allowed. In case of a date field, the array must be d3server_date_1_array, while it would be d3server_value_num_allowed for a numeric value. The date must be entered in the German notation “DD.MM.YYYY”.

Finally in row 19 the ID of the advanced property field will be assigned to a global array. This ID is passed on to the hook-function by the d.3 server during the function call (line 6).

Further literature on the topic of “hook-development" can be requested from d.velop AG.