Printing in CRM

I apprecaite this is a well documented subject but I am trying to Print from a custom Module I have created (Create a PDF Report).

I have made alterations to files as per the enclosed but get an error stating;
“There was an error processing your request, please try again later” when altyering the detailview.php within my custom module.
I have disabled Ajax as instructed but the error still occurs.

The Code that effects the error is when i place (within Detailview.php) the following line;

// add option like this (may vary slightly but function is the same, if list is different exclude “4 =>”) 4 => array ( 'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">',

Do I need to make any alterations in php.ini?
Any advice would be greatly appreciated.

The Full instructions and code I am following is listed below (instructions), this code seems popular on this Forum for printing PDF from Custom Modules.

Many Thanks in advance.


Adding Print PDF Function to any module in SuiteCRM.

1 ) First We need to add your custom module in to *Type drop down of PDF template module

This We can do it by going to Admin > Drop Down Editor, We need to search for pdf_template_type_dom drop down list and add -> option

Item name [ your custom directory name ] : To find the proper name path, FTP into the SuiteCRM server and go to modules and use the exact name used on your module file Display label [ Whatever name you want ]
Save it .

2 ) After this We need Print as pdf option in our details view page of custom module

  • to add option in details view page open detailviewdefs.php
    we can find this file under /custom/modules//metadata/detailviewdefs.php

we need to add option in to buttons array

array ( '
buttons' => 
array ( 
0 => 'EDIT', 
1 => 'DUPLICATE', 
2 => 'DELETE', 
3 => 'FIND_DUPLICATES', 
// add option like this (may vary slightly but function is the same, if list is different exclude “4 =>”)
 4 => array ( 'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">', ),

save it and check if you are not able to see the option. <-optional but recommended to make sure everything is good at this point.

You are using an existing detailviewdefs.php file (created by Studio) and editing it, right?

You must be messing up the PHP in some detail. Can you post the full file, before and after the edit, inside the Forum’s code tags?

Or here if you prefer: https://pastebin.com

Hi PGR many thanks for your reply.
I enclose 2 copies of detailviewdefs.php as requested.

  1. The first chunk of code is as generated by Studio WITHOUT any added code.

  2. The second chunk of code is with custom code added.

  3. Code as generated in Studio (No Added Custom Code)

<?php
$module_name = 'rk321_VForm';
$_object_name = 'rk321_vform';
$viewdefs [$module_name] = 
array (
  'DetailView' => 
  array (
    'templateMeta' => 
    array (
      'form' => 
      array (
        'buttons' => 
        array (
          0 => 'EDIT',
          1 => 'DUPLICATE',
          2 => 'DELETE',
          3 => 'FIND_DUPLICATES',
        ),
      ),
      'maxColumns' => '2',
      'widths' => 
      array (
        0 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
        1 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
      ),
      'useTabs' => true,
      'tabDefs' => 
      array (
        'DEFAULT' => 
        array (
          'newTab' => true,
          'panelDefault' => 'expanded',
        ),
  1. Code Generated in Studio WITH Added custom code (When Error appears)
<?php
$module_name = 'rk321_VForm';
$_object_name = 'rk321_vform';
$viewdefs [$module_name] = 
array (
  'DetailView' => 
  array (
    'templateMeta' => 
    array (
      'form' => 
      array (
        'buttons' => 
        array (
          0 => 'EDIT',
          1 => 'DUPLICATE',
          2 => 'DELETE',
          3 => 'FIND_DUPLICATES',
          // add option like this (may vary slightly but function is the same, if list is different exclude “4 =>”) 
          4 => array ( 'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');" value="{$MOD.LBL_PRINT_AS_PDF}">',
        ),
      ),
      'maxColumns' => '2',
      'widths' => 
      array (
        0 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
        1 => 
        array (
          'label' => '10',
          'field' => '30',
        ),
      ),
      'useTabs' => true,
      'tabDefs' => 
      array (
        'DEFAULT' => 
        array (
          'newTab' => true,
          'panelDefault' => 'expanded',
        ),

Looks ok to me… :huh:

When you get that “try again later” error on your screen, do you get any other message in one of your two logs?

Hi PGR, again many thanks for your help.

To confirm, no errors are showing in the logs.

To give an overview of setup (if that helps);
Operating system of Platform: Windows using Xampp.

The system is stable and all modules (origional and custom) operate correctly.
The Network is stable and we do not experience any issues other than the code when placed in the detailviewdef.phjp file of the custom module.

Im very much on a time scale to get this operational so any help would be greatly appreciated.

Many thanks in advance.

XAMPP gives tons of problems when display_errors is on, in php.ini

Make sure you turn it off and restart XAMPP. Tell me if anything changes.

Hi PGR

display_errors was already set to off ?

Thanks again

I’m sure you must have something in your logs.

Are you checking both? suitecrn.log AND php_errors.log or whatever the XAMPP log is called.

You can also raise your log level to see more messages (Admin / system settings)

Sorry for the late reply.

Enclose PHP log data

[10-May-2019 15:25:42 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:25:42 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:25:46 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:25:46 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:09 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:09 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:18 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:18 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:21 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:21 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:23 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:23 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:24 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:24 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:27 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:27 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:32 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:32 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:34 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:34 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:37 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:37 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:43 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:43 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:26:46 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:26:46 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:27:18 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:27:18 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545
[10-May-2019 15:27:22 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2531
[10-May-2019 15:27:22 Europe/Berlin] PHP Warning:  "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in C:\xampp\htdocs\CRM\data\SugarBean.php on line 2545

What is your SuiteCRM version?

And your PHP version?

Thanks

Hi PGR,
Again, many thanks for your assistance.

SuiteCRM Version is 7.10.10
PHP Version is 7.3.0

Any Ideas?

If you can try the latest in your branch, at least in a test environment, I believe there’s a chance your problem would be solved. I think I’ve seen it before, a few months ago, though I am not sure where in the code those warnings were coming from - maybe these positions you’re getting, maybe different ones.

Another option would be to try it with an older PHP version. 7.3 is quite new, and we don’t even support it yet, because there can be small problems like these that still need to be fixed.

https://docs.suitecrm.com/admin/compatibility-matrix/

I am using PHP 7.3 myself, but I think of it as a test lab. It’s working fine so far, but XAMPP can be different.