#832 - Filter subpanel records by condition - how to set?
Hi Is it possible to filter subpanel records by condition (example: "status" of record wich is dropdown value)? Then sort selected records by some field And then generate document
Thanks
Hi Is it possible to filter subpanel records by condition (example: "status" of record wich is dropdown value)? Then sort selected records by some field And then generate document
Thanks
10 years ago
Please see custom/modules/Opportunities/DHA_DocumentTemplatesCalculatedFields.php example for Calculated Fields - ShowRow event to filter main module data - OrderRows event to order main module data - BeforeMergeBlock event to order and/or filter subpanel data.
The BeforeMergeBlock event example is only to order data (Opportunities subpanel data in Accounts report), but you can apply any filter you need too, filtering $this->Generate_Document_Instance->datos['main_key_xxxxxxx']['opportunities'] array (in the example).
10 years ago
hi I tried but no success. Looks like BeforeMergeblock function not work for me... Main module is kir_kp, so custom class is Customkir_kp_DocumentTemplatesCalculatedFields subpanel module is kir_deal_items, so i renamed 'opportunities' into 'kir_deal_items' in BeforeMergeBlock example i want to filter subpanel data by field status_id = 'Active' then i tried several variants, but no success (even added condition directly to sql statement) file with class and function is placed to custom/modules/kir_kp folder (as main module folder) Can you explain how to make it work in my case? MMR 2.2 Thanks in advance
10 years ago
here is the text of the function
function BeforeMergeBlock() { // Order rows example for submodule data. In this example we order opportunities related to account (in account report). // Please note that this event for this example must be placed in Accounts calculated fields class, not here // To order rows in MainModule, use OrderRows event (easier to use)
if($data['status_id'] == 'Active'){ // my condition $data_array_ids[] = $data['id']; $data_array_keys[$data['id']] = $key; } }
}
10 years ago
We will add the next filter example in next version of MMR (filter Contacts subpanel of Opportunities): https://gist.github.com/anonymous/df03390386ba6c89ebe4
This example will be placed too in the BeforeMergeBlock event, in custom/modules/Opportunities/DHA_DocumentTemplatesCalculatedFields.php
You will need to create the next file : "custom/modules/kir_kp/DHA_DocumentTemplatesCalculatedFields.php" Add the next require "require_once('modules/DHA_PlantillasDocumentos/DHA_DocumentTemplatesCalculatedFields_base.php');" Create a Calculated field class with the name "Customkir_kp_DocumentTemplatesCalculatedFields" Create a BeforeMergeBlock event Copy in this event the new example (uncoment first) Replace or remove the "plantilla_id" filter Replace "contacts" with "kir_deal_items" Change the filter condition for ...
if ($data['status_id'] == 'Active') { $data_array_new[] = $data; } Ensure that filter condition is OK
10 years ago
hi I did as described, but filter not works. All subpanel records are in the report. What you mean create event BeforeMergeBlock? Function BeforeMergeBlock as in the opportunities example? Thanks
10 years ago
Yes, create Function BeforeMergeBlock as in the opportunities example
10 years ago
Hi MMR is updated to 2.4 but no success on sorting subpanel records in generated Document Used code from example from opportunities, changed query_table and field_name in SQL statement ORDER BY also changed opportunities into my child module_name kir_deeal_items File is placed in custom/main_module_folder No success it never goes inside condition if ($this->inMainModule() && !empty($this->Generate_Document_Instance->datos)) Any suggestions?
10 years ago
created new case https://www.sugaroutfitters.com/support/mail-merge-reports/917 and corrected condition in BeforeMergeBlock pointed above