CoreBOSBB
GenDoc: can't get to related record tree - Printable Version

+- CoreBOSBB (https://discussions.corebos.org)
+-- Forum: Support (https://discussions.corebos.org/forumdisplay.php?fid=17)
+--- Forum: Administrator Support (https://discussions.corebos.org/forumdisplay.php?fid=8)
+--- Thread: GenDoc: can't get to related record tree (/showthread.php?tid=1615)



GenDoc: can't get to related record tree - Guido1982 - 10-30-2019

I have this in a gendoc template I use on an invoice:
Code:
{foreach MyModule}
{foreach CobroPago}
{CobroPago.reference}        € {CobroPago.amount}
{/foreach}
{/foreach}
Where 'MyModule' is a custom module that has is related to the invoice and the CobroPago (Payment) records are in turn related to 'MyModule'. For some reason I can show fields from 'MyModule' but not from the Payment (CobroPago) records. What am I doing wrong?


RE: GenDoc: can't get to related record tree - joebordes - 10-30-2019

Looks correct to me. I suppose the relation MyModule > CobroPago is a normal get_related_list?


RE: GenDoc: can't get to related record tree - Guido1982 - 10-31-2019

No, in fact there are two custom 'get_related_...' functions I built to create custom related lists. I was afraid that would be the issue. How could I get around this?


RE: GenDoc: can't get to related record tree - joebordes - 11-01-2019

that is probably the issue, depending on how you return the SQL probably.

first try using the direct document generation (accessing GenDoc module directly) with Debug active, to see if you can find some information about what it is doing on that foreach


RE: GenDoc: can't get to related record tree - Guido1982 - 11-01-2019

Is there some documentation on debugging gendoc templates? I'm not sure how to do it.


RE: GenDoc: can't get to related record tree - joebordes - 11-01-2019

first, go to the module: index.php?module=evvtgendoc&action=index
that will take you to a direct generator where you pick the template, module, language and if you want to see debug information or not
then the fun is trying to understand what the outputmeans :-)


RE: GenDoc: can't get to related record tree - Guido1982 - 11-03-2019

:-)
Cool, let me try that and report back here

OK so the debug didn't really do that much, other than provide me with some search terms to get me going in modules/evvtgendoc/compile.php. There I found this. I don't take this global variable assigment into account, nor do I adhere to query formatting of any kind in my related functions.

What I will try to do is check for the global '$GetRelatedList_ReturnOnlyQuery' in my custom related function and if so, call the 'regular' get_related_list function.


RE: GenDoc: can't get to related record tree - Guido1982 - 11-03-2019

OK so this is pretty much solved. What you want to do when creating related list custom functions is fall back to the default SQL when 'SQL only' is required. Suppose your custom function looks something like:
PHP Code:
public function get_custom_related($id$tabid$rel_tabid$actions false) {
 
   global $adb;
 
   // Do some custom stuff

Then you would add a couple of fallback lines:
PHP Code:
public function get_custom_related($id$tabid$rel_tabid$actions false) {
 
   global $adb$GetRelatedList_ReturnOnlyQuery;

 
   if ($GetRelatedList_ReturnOnlyQuery) {
 
       return $this->get_dependents_list($id$tabid$rel_tabid);
 
   }
 
   // Do some custom stuff

Where you would choose to fallback either on 'get_dependents_list' or 'get_related_list' based on what your custom function sees as a 'relation'.


RE: GenDoc: can't get to related record tree - joebordes - 11-03-2019

Very interesting
Thanks for sharing!