Announcement

Collapse
No announcement yet.

PDF Report Template placeholder not printing..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • PDF Report Template placeholder not printing..

    This is just not working for me and I have no idea why:

    I have a custom "Event" entity that includes another custom "Base" entity, very basic stuff. I have a template for the Base entity with a placeholder like this: {{event.parentName}}. This is a totally valid placeholder. The parent of the Event is an account and it is clearly set in the Event but the name of the parent just doesn't want to appear in the PDF print. It's always totally blank. The PDF displays everything else correctly just the {{event.parentName}} is always blank. And this for me is the main heading of this particular report, without the parent name the report is confusing.

    Please some help.. thanks.

  • #2
    By the way, I should mention the placeholder {{event.parentId}} displays the id of the parent just fine.

    Comment


    • #3
      Hi,
      you want to use related entity data of related entity.
      Define for your Entity in Service the method loadAdditionalFieldsForPdf and load this data for event

      EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

      you can call loadAdditionalFieldsForList with event service
      Last edited by tanya; 05-08-2018, 09:32 AM.

      Comment


      • #4
        Sorry, but I just bought the advanced pack last week and totally new to the system. I have no idea what file to modify for this and I don't understand what code to write. I know how to develop in PHP, JavaScript, etc.. but I don't know the design pattern of EspoCRM and don't know how the system is laid-out.

        My custom entity is called 'BEO' and it has a relationship to another custom entity 'Event' by (BEO)Many-to-One(Event). The 'Event' entity has a Parent (Account or Contact) and that's the entity I want to get the "Name" of.

        I opened the "BEO.php" file under ".\htdocs\crm\custom\Espo\Custom\Services" and modified to this:

        namespace Espo\Custom\Services;

        class BEO extends \Espo\Core\Templates\Services\Base
        {
        public function loadAdditionalFieldsForPdf (Entity $entity)
        {
        $this->loadAdditionalFieldsForList($entity);
        }
        }


        But that didn't work and the PDF doesn't load with the above modification.

        Should I add the "loadAdditionalFieldsForPDF" function here? How do I call the "loadAdditionalFieldsForList" function?

        Thanks!

        Comment


        • #5
          Just read the code. Is not so simple as I think.
          At first create notStorable varchar field in BEO entityDefs (for example "eventParentName"). And in template you need to use {{eventParentName}} placeholder
          https://forum.espocrm.com/forum/deve...management-tab

          in loadAdditionalFieldsForPdf you need to set eventParentName the value
          something like

          Code:
          namespace Espo\Custom\Services;
          
          class BEO extends \Espo\Core\Templates\Services\Base
          {
              public function loadAdditionalFieldsForPdf (Entity $entity)
              {
                   $parentName = '';
                   if ($entity->get('eventId')) {
                       $event = $this->getEntityManager('Event', $entity->get('eventId'));
                       $event->loadParentNameField('parent');
                       $parentName = $event->get('parentName');
                   }
                   $entity->set("eventParentName", $parentName);
          
              }
          }

          https://github.com/espocrm/espocrm/b...es/Pdf.php#L79
          https://github.com/espocrm/espocrm/b...r/Htmlizer.php
          Last edited by tanya; 05-09-2018, 12:11 PM.

          Comment

          Working...
          X