Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(WIP) Add message template content as activity #34

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jofranz
Copy link
Member

@jofranz jofranz commented Feb 21, 2023

Comment on lines +165 to +174
private function getMessageTemplate($id): array
{
try {
return \Civi\Api4\MessageTemplate::get()
->addWhere('id', '=', $id)
->execute()
->single();
} catch (UnauthorizedException|CRM_Core_Exception $e) {
throw new Exception(E::LONG_NAME . " " . "Unable to fetch message template $id. Error: $e");
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jensschuppe Is there a example implementation in one of our extensions to fill tokens with content as V3 API is doing it automatically using MessageTemplate::send in my previous implementation?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API3's MessageTemplate.send doesn't return the result, but CRM_Core_BAO_MessageTemplate::sendTemplate(), which basically does all the work inside it, does. So maybe it'd be worth not using the API but this method for getting the contents for passing it into the creation of an activity. You might have to adjust parameters, so check what civicrm_api3_message_template_send() is doing before.

Rendering the template a second time for creating the activity doesn't seem to make sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants