Hello,
Can someone please help me in defining the code snippet to display a 'nested' relation in PDF Template?
Example:
PDF Template Entity - MainEntity
Relations:
The following PDF Template (based on MainEntity) will display subEntities Fields quite nicely:
But how do we display subSubEntities fields? I thought maybe this would work but it doesn't ....
So how does one access subSubEntities ? It seems this was done using loadAdditionalFields method in custom\Espo\Services\MainEntity.php in prior versions of Espo and defining nonStorableField but this doesn't seem to be working in Espo 7.2 ?
I see there are two files in Espo 7.2 which seem to indicate this is how to load extra data in PDF Template entity but there are no examples on how to use these? Is this the proper way to do this in Espo 7.2 or is there another way using Services & nonStorable Fields or a different syntax for code snippet above?
\Modules\Crm\Resources\metadata\pdfDefs\Account.js on
\Modules\Crm\Pdf\Account\ExampleDataLoader.php
esforim
telecastg
Can someone please help me in defining the code snippet to display a 'nested' relation in PDF Template?
Example:
PDF Template Entity - MainEntity
Relations:
Entity | Foreign Link | Link Type | Link | Foreign Entity |
MainEntity | mainEntity | One-to-Many | subEntities | SubEntity |
SubEntity | subEntity | One-to-Many | subSubEntities | SubSubEntity |
SubEntity | subEntities | Many-to-One | account | Account |
Code:
{{#each subEntities}} {{name}} {{account.name}} ... {{/each}}
Code:
{{#each subEntities}} {{#each subSubEntities}} {{name}} {{/each}} ... {{/each}}
So how does one access subSubEntities ? It seems this was done using loadAdditionalFields method in custom\Espo\Services\MainEntity.php in prior versions of Espo and defining nonStorableField but this doesn't seem to be working in Espo 7.2 ?
I see there are two files in Espo 7.2 which seem to indicate this is how to load extra data in PDF Template entity but there are no examples on how to use these? Is this the proper way to do this in Espo 7.2 or is there another way using Services & nonStorable Fields or a different syntax for code snippet above?
\Modules\Crm\Resources\metadata\pdfDefs\Account.js on
Code:
{ "dataLoaderClassNameList": [ "Espo\\Modules\\Crm\\Classes\\Pdf\\Account\\ExampleDataLoader" ] }
\Modules\Crm\Pdf\Account\ExampleDataLoader.php
PHP Code:
namespace Espo\Modules\Crm\Classes\Pdf\Account;
use Espo\Tools\Pdf\Data\DataLoader;
use Espo\Tools\Pdf\Params;
use Espo\ORM\Entity;
use stdClass;
class ExampleDataLoader implements DataLoader
{
public function load(Entity $entity, Params $params): stdClass
{
// Here you can load additional data for PDF;
return (object) [
];
}
}
telecastg
Comment