hooks function from video part 4 not explicit

Firekenny

New member
Hello,
I have watched the video explaining the hooks function but the exemple provided does not really complete the process as it does not explain which field of which form the dadabik_send_low_inventory_email function should be placed (in the form configurator, calculated field function field).

First question:
As I understood in this particular example, there are 2 tables. The "Products" table (the main data) and the "Sales" table (a separate table with its own form where user would pick the product from a drop down menu - where the related field form will have "field type" = "select_single" and "lookup table" = "products", "lookup table primary key"= "id_products" and "lookup table linked field" = "desc_product").

Once the user enters the "quantity_sale" in the related field from the Sales form/table, the quantity will automatically update the "quantity_product" from the "Products table".

So in order for this to work, where would the custom function be placed? (which "calculated field function" field from which form).

Second question:
If instead of sending an email in the select query section, I want to fetch additional data from "products table" (such as desc_product and quantity product - ensuring I can sell qty that I have on stock before finalising the sale) and display the relevant product details, what is the relevant code to add in the custom function?
Would this require to have additional fields in my "sales table" in order to fetch and display the relevant details from "product table" in the "sales form"?

Thanks for your support.
________________________________________________________________________________
You are using DaDaBIK version 9.4-Monterosso enterprise, installed on 10-04-2019 (installation code: 149385d97a1a893918), the latest version of DaDaBIK is 9.4-Monterosso released on 07-23-2019

You are runnning the last release of DaDaBIK

PHP Version: 7.1.32

mysql version: 5.5.5-10.4.6-MariaDB

Web server: Apache/2.4.41 (Unix) OpenSSL/1.1.1c PHP/7.1.32 mod_perl/2.0.8-dev Perl/v5.16.3

Client: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.1 Safari/605.1.15
 

eugenio

Administrator
Staff member
Hello,
operational hooks are not related to one field, they are linked to one table and event (see the documentation) so you don't have any place to put them in the form configurator.

About the second question: I am not sure where you want do display the information, but operational hooks are not used to display content in the user interface. You can display content with layout hooks (see documentation) but I don't think it's exactly what you are looking for.

More in general, when it comes to custom code we can give advices and also provide small pieces of code, but providing the complete code for a custom function is generally beyond the scope of this support.

Best,
 
Top