Print to PDF: Uncaught ReferenceError: showPopup is not defined

I’m trying to add ‘Print to PDF’ to the Opportunities module and added the following to custom/modules/Opportunities/metadata/detailviewdefs.php :-

'AOS_GENLET' =>
          array(
            'customCode' => '<input type="button" class="button" onClick="showPopup();" value="{$APP.LBL_PRINT_AS_PDF}">',
          ),

The menu item appears, but when clicking i get the following error :-1:

"Uncaught ReferenceError: showPopup is not defined… at HTMLInputElement.onclick "…

I have looked at other modules (eg Accounts) and the code for button array is the same, what could be causing the error? I have deleted the custom folder and the error remains.

i needed to add

function display(){	             
	if(empty($this->bean->id)){
		global $app_strings;
		sugar_die($app_strings['ERROR_NO_RECORD']);
	}       
	require_once('modules/AOS_PDF_Templates/formLetter.php');
	formLetter::DVPopupHtml('Opportunities');		
	$this->dv->process();
	global $mod_strings;	
	echo $this->dv->display();
}

to custom\modules\Opportunities\views\view.detail.php

2 Likes