Empty Property When Print PDF Using AOS PDF Template


I’m using AOS PDF Template to create PDF Invoice. However when I click create PDF, it is showing like this :
Fatal error: Cannot access empty property in /home/suitecrm/public_html/suitecrm/modules/AOS_PDF_Templates/templateParser.php on line 47

If I comment the line,

$repl_arr[$key."_".$field_def[‘name’]] = $focus->$field_def[‘name’];

Then it can generate PDF although some field is not showing.

I have create some custom field on invoice, but when I delete all the custom field, the error is still showing.

Can you help me? Thc


What version of SuiteCRM are you running?

In SuiteCRM 7.3.2, my line 47 in that file is:

$repl_arr[$key."_".$field_def[‘name’]] = $focus->$field_def[‘name’];

and I have no issue creating PDFs

Hi, thanks for the response. I’m using suitecrm 7.2.1. Actually, I have two instances of suitecrm, one installed on local and the other are installed on my online server. The one installed on local server are working but the other on hosted server are not working. The difference is, on the hosted server, I’m adding custom field on invoice. I’d like to know if adding custom field affected the generation of pdf because it is very hard to debug the error. It is not showing on sugarcrm.log or suitecrm.log.

I have a fix for this problem.

Look here for the github thread: https://github.com/salesagility/SuiteCRM/issues/620

The problem most likely is occuring because you have a null field in studio, so when it goes to access ‘null’, it can’t.

In /modules/AOS_PDF_Templates/templateParser.php on line 47

I fixed this by modifying that last else statement to be:

else if(isset($focus->$field_def['name'])){
       $repl_arr[$key."_".$field_def['name']] = $focus->$field_def['name'];

This way, it won’t iterate through the property if its null. Being that this problem happens quite frequently and I can’t always go manually erasing the file from my code. In this case, I had modified the ‘Generate Letter’ function to work in the Opportunities module and had a null field there.

In addition, following this fix may also solve the problem as well.