How to access business custom fields in custom theme

I am creating a custom theme for our invoices and credit notes. I realise custom themes are now classified as obsolete, but as per previous topics (here and here, for example) there isn’t yet (as far as I know) any other way to create invoices that comply with our local fiscal device requirements (Zimbabwe).

Here is a section of my theme code:

<tr>
	<td>
		<div style="font-weight: bold">{{ business.name }}</div>
		<div>{{ business.address | newline_to_br }}</div>
		{% if business.custom_fields["BusinessPhone"] != null %}
			<div><b>Phone: </b>{{ business.custom_fields["BusinessPhone"] }}</div>
		{% endif %}
		{% if custom_fields["BusinessPhone"] != null %}
			<div><b>Phone: </b>{{ custom_fields["BusinessPhone"] }}</div>
		{% endif %}
		{% for field in business.custom_fields %}
			<div>{{ field.label }} {{ field.text }}</div>
		{% endfor %}
	</td>
	<td>
		<div style="font-weight: bold; text-align: right; margin-right: 10px">Bill to:</div>
	</td>
	<td>
		<div style="font-weight: bold">{{ recipient.name }}</div>
		<div>{{ recipient.address | newline_to_br }}</div>
		{% if custom_fields["Phone"] != null %}
			<div><b>Phone: </b>{{ custom_fields["Phone"] }}</div>
		{% endif %}
		{% if recipient.email != null and recipient.email != "" %}
			<div><b>Email: </b>{{ recipient.email | newline_to_br }}</div>
		{% endif %}
		{% if custom_fields["TIN"] != null %}
			<div><b>TIN: </b>{{ custom_fields["TIN"] }}</div>
		{% endif %}
		{% if custom_fields["VAT number"] != null %}
			<div><b>VAT number: </b>{{ custom_fields["VAT number"] }}</div>
		{% endif %}
	</td>
</tr>

The section with the recipient custom fields is working fine, but none of the three options I’ve tried to retrieve the business custom fields is working (business.custom_fields["BusinessPhone"], custom_fields["BusinessPhone"], or {% for field in business.custom_fields %}).

I realise the icon for Business details doesn’t show the text – that seems to happen consistently for me across all custom fields but just for Business details, so perhaps is an unrelated bug?

My searching of the forum yielded several results which suggested that the {{ business.custom_fields["Field name"] }} syntax used to work. See here, here, and here, for example.

So, I’m wondering if the implementation has changed (those posts are now several years old), or am I doing something wrong? If there’s nothing I can do to fix it, then the workaround I will probably have to do is to add the data for those business custom fields as fixed text in the business address field. The pedant in me would rather be able to use the custom fields as such, but with themes being an obsolete feature now I don’t expect to get much sympathy from the developer or other forum users (although this post from @lubos makes me wonder if he might be open to restoring the lost functionality).

Classic custom fields can still be used in Business Details.

this code for direct call to BusinessPhone

{% if business.custom_fields["BusinessPhone"] != null %}
	<div><b>Phone: </b>{{ business.custom_fields["BusinessPhone"] }}</div>
{% endif %}

1 Like

I followed the instruction in this request but after hours of trying no luke. I know the template is an obsolete option. But does the business.custom_fields option in the HTML still works or is there an alternative?
I use manager.io 24.4.17.1441 on a desktop.

Why not just try it and find it out by yourself?

1 Like

I tried several mentioned option.

{% for field in business.custom_fields %}
<div>{{ 'Telefoonnummer: 0123344888' | newline_to_br }}</div>
<tr>
<td>{{ field.label }} :</td>
<td>{{ field.text }}</td>
</tr>
{% endfor %}

Only telefoonnummer is shown.

<div>{{business.custom_fields['Telefoonnummer'].label}}  {{business.custom_fields['Telefoonnummer'].text}}</div>

No result

<div>{{business.custom_fields['Telefoonnummer']}}  {{business.custom_fields['Telefoonnummer']}}</div>

No result

<div>{{business.custom_fields["Telefoonnummer"]}}  {{business.custom_fields["Telefoonnummer"]}}</div>
No result

<div>{{business.custom_fields["Telefoonnummer"] | newline_to_br}}</div>
no result

Try Settings - Obsolete Features -Classic Custom Fields for Business Details

1 Like

Thank you so much @Mabaega I have learnt a lot with your guidance. :slightly_smiling_face: