In an email, a token from an extension in a subject will inhibits the same token group in the email body
In an email, if I put a custom token {custom.name} as a subject and other custom token in the email body and then send the email.
Subject: {custom.name}
Email Body
Name: {custom.name}
Age: {custom.age}
Gender: {custom.gender}
I will only receive the value of the {custom.name} that's in the subject. The other custom token in the email body will be blank.
Subject: Custom Name Value
Email Body
Name: Custom Name Value
Age:
Gender:
In my investigation, this is what I found out.
- The issue will not appear if you use the default token like contact in the subject and email body.
- The issue will not appear if you will not use a custom token in the subject.
- If you use custom token as a subject and put a contact token and other custom token in the email body, only the contact token will appear. This issue will only affect the same token group that you put on the subject.
- This issue will also appear on other extension with a
tokens
andtokenValues
hook. Check this contact from the demo site with this issue using fancy tokens. (Check June 30th, 2021 emails)
I conclude that this is a core issue base on my findings.
A possible fix for this issue is changing this line of code $allTokens = array_merge($messageToken, $subjectToken)
to $allTokens = CRM_Utils_Array::crmArrayMerge($messageToken, $subjectToken);
.
Here is the main issue for more details: Related Tokens Issue 15.