3

I have the same problem as at http://forum.civicrm.org/index.php/topic,32608

I have created a tokenValues hook to fetch the value of a field from a multi-record custom field set. I have the token hook embedded within a message template. The hook works fine and correctly populates the value if I trigger it from Actions->Send an email. But when triggered by a Scheduled Reminder based on x days before end of membership, the value is not filled in within the email that goes out.

I have logging within the token hook which shows that the hook is being called and is populating the returned array with the correct value. I tried to debug further, but I can't figure out from where the tokenValues function is being called. So I can't figure out why the behavior is different for Action->Send an email vs Scheduled Reminders.

If necessary, I can work around this by running a script to push the value I want into a non multi-record field, as regular custom fields work fine. But obviously that's a bit of a cludge, and this seems like a bug in CiviCRM.

This is a different issue than that described at Token not evaluating in CiviMail - that's discussing custom field permissions, which aren't a problem here.

  • I forgot to mention: the tokenValues hook, when called, is passed a $context value of 'CRM_Activity_BAO_Activity' – Norris Jun 27 '15 at 15:27
3

I ran into a similar issue of custom tokens not populating for scheduled reminders. The workaround in Brian Shaughnessy's comment on CRM-11153 fixed it for me:

early in tokenValues put:

$single = false;
if (!is_array($contactIDs)) {
    $contactIDs = array( $contactIDs );
    $origValues = $values;
    $single = true;
}

then at the very bottom put:

if ($single) {
    $values = $origValues + $values[$id];
}

$id may be something different in your hook implementation.

Other recent comments on that issue suggest that a fix may find its way into CiviCRM core.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.