Using the Explorer, I built up the smarty code I need for a template to pull in address information on a contact for use in an email:
{crmAPI var='result' entity='Address' action='get' contact_id=203}
{foreach from=$result.values item=address}
{$address.some_field}
{/foreach}
and it produces the desired output in the Explorer when executed.
In an email though, the expected output never renders, and when I add the smarty expression {result|@debug_print_var}
, I get null
for the value of the variable in the message.
The fact that I'm getting null
suggests to me that smarty is in fact running, but I can't for the life of me figure out why it can't seem to make an API call. Thoughts?
Thanks for the help!
N.B.: I'm running CiviCRM 5.17.4 on Drupal 7.67 and Ubuntu 16.04.
Update
With the following email code:
{capture assign=contact_id}{contact.contact_id}{/capture}
id: {contact.contact_id}
smarty id: {$contact_id}
{crmAPI var='result' entity='Contact' action='get' id=203}
{$result|@debug_print_var}
This is the email that renders when sending to contact # 203:
id: 203
smarty id: 203
null