by Izertis

Create documents in docx, xlsx (MS Office Word and Excel), odt, ods (LibreOffice and OpenOffice) and pdf format without MS Office or others plugins installed from any module and subpanel using templates.

Includes a 30 day guarantee
Try it Now

By clicking you consent to share your profile with the developer

#403 - Name of the generated document - how to set?

Closed General Question created by kir 10 years ago

hi How to set name of the generated file? Let's say name should be generated (calculated) and contain values of the fields from source record...

  1. dharma member avatar

    Izertis Provider

    10 years ago

    The name is generated from the original uploaded template. Let's say, we upload a template named 'mytemplate.docx', then the generated file will be 'mytemplate.docx'.

    But you can change this with calculated fields, and BeforeMergeBlock event, assigning $this->Generate_Document_Instance->template_filename (this don't work for PDF generation). Take care of the document name generated when the process is called from Listview. This is a example for Opportunities calculated fields:

    function BeforeMergeBlock() { // Not for PDF ... if (!$this->Generate_Document_Instance->enPDF) { $document_name = 'opportunities' . ' - ' . date('Y-m-d');

         // Not for listview ...
         if ($this->inMainModule() && !empty($this->Generate_Document_Instance->datos) && count($this->Generate_Document_Instance->datos) == 1) {
            $document_name = $this->Generate_Document_Instance->datos[1]['name'] . ' - ' . date('Y-m-d');
         }
    
         $this->Generate_Document_Instance->template_filename = $document_name . '.' . $this->Generate_Document_Instance->template_file_ext; 
      }      
    

    }

    Please, note that this can change in future versions ... maybe a new property to work too for PDF.

    • dharma member avatar

      Izertis Provider

      10 years ago

      sorry, the example code has been corrupted when I upload it. Again with markdown ...

         function BeforeMergeBlock() { 
            // Not for PDF ...
            if (!$this->Generate_Document_Instance->enPDF) {
               $document_name = 'opportunities' . ' - ' . date('Y-m-d');
               // Not for listview ...
               if ($this->inMainModule() && !empty($this->Generate_Document_Instance->datos) && count($this->Generate_Document_Instance->datos) == 1) {
                  $document_name = $this->Generate_Document_Instance->datos[1]['name'] . ' - ' . date('Y-m-d');
               }
               $this->Generate_Document_Instance->template_filename = $document_name . '.' . $this->Generate_Document_Instance->template_file_ext; 
            }      
         }
      
    • dharma member avatar

      Izertis Provider

      10 years ago

      https://gist.github.com/anonymous/d482b68107b83b413c7a

  2. rossella member avatar

    rossella

    10 years ago

    What about the Community Edition with no Sugar logic for calculated fields?

  3. dharma member avatar

    Izertis Provider

    10 years ago

    If you mean the Basic version of the component, there is no calculated fields. Calculated fields are present only in Premium version. See "Basic version limitations" section in the readme.txt

  4. rossella member avatar

    rossella

    10 years ago

    Sorry, I'm new to the plugin and if I go to "View pricing" I can see only the Premium version. Where should I find the Basic one?

    • dharma member avatar

      Izertis Provider

      10 years ago

      http://www.sugarforge.org/projects/plantillasword

This case is public. Please leave out any sensitive information such as URLs, passwords, etc.
Saving Comment Saving Comment...
Rating