Custom field in pdf invoice don't work on all client records

Hi, I went over the WIKI and several posts about custom fields and pdf invoice.

My problem is that after adding:

<?php echo $custom_fields['client']['Service Address']; ?> 

the newly created clients and their invoices display the custom field OK, unfortunately all remaining old - existing clients and already created invoices trow error:

A PHP Error was encountered
Severity: Notice
Message: Undefined index: Service Address
Filename: pdf/InvoicePlane.php
Line Number: 55
Line: 55
Function: _error_handler
Line: 464
Function: include
Line: 415
Function: _ci_load
Line: 102
Function: view
Line: 266
Function: generate_invoice_pdf
File: /home/xxxxxxx/xxxxxxx/invoice/index.php
Line: 325
Function: require_once

Thant is because all records that does not have entered data inside this custom filed return error. So, how to get around this issue so when the client record have custom field: ‘Service Address’ with value to display it, and when there is no entered data to display the invoice without trowing the error?

Hey, I found solution here is how work, using IF/ELSE to eliminate the records that does not contain data in the custom field.

    <p><strong>Service Address: </strong>
        if (isset($custom_fields['client']['Service Address'])) {
            echo $custom_fields['client']['Service Address'];
            echo 'No Service Address provided' . '<br />';
1 Like