2

When a person is assigned any activity, the information goes as a form. However, I would also like to include the phone number and email address of the person from whom the event was created. How can I do that.

administrator/?option=com_civicrm&task=civicrm/admin/messageTemplates/add&action=update&id=1&reset=1

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
 <title></title>
</head>
<body>

{capture assign=headerStyle}colspan="2" style="text-align: left; padding: 4px; border-bottom: 1px solid #999; background-color: #eee;"{/capture}
{capture assign=labelStyle }style="padding: 4px; border-bottom: 1px solid #999; background-color: #f7f7f7;"{/capture}
{capture assign=valueStyle }style="padding: 4px; border-bottom: 1px solid #999;"{/capture}

<center>
 <table width="620" border="0" cellpadding="0" cellspacing="0" id="crm-event_receipt" style="font-family: Arial, Verdana, sans-serif; text-align: left;">

  <!-- BEGIN HEADER -->
  <!-- You can add table row(s) here with logo or other header elements -->
  <!-- END HEADER -->

  <!-- BEGIN CONTENT -->

  <tr>
   <td>
    <table style="border: 1px solid #999; margin: 1em 0em 1em; border-collapse: collapse; width:100%;">
     <tr>
      <th {$headerStyle}>
       {ts}Activity Summary{/ts} - {$activityTypeName}
      </th>
     </tr>
     {if $isCaseActivity}
      <tr>
       <td {$labelStyle}>
        {ts}Your Case Role(s){/ts}
       </td>
       <td {$valueStyle}>
        {$contact.role}
       </td>
      </tr>
      {if $manageCaseURL}
       <tr>
       <td colspan="2" {$valueStyle}>
     <a href="{$manageCaseURL}" title="{ts}Manage Case{/ts}">{ts}Manage Case{/ts}</a>
       </td>
       </tr>
      {/if}
     {/if}
     {if $editActURL}
     <tr>
       <td colspan="2" {$valueStyle}>
   <a href="{$editActURL}" title="{ts}Edit activity{/ts}">{ts}Edit activity{/ts}</a>
       </td>
     </tr>
     {/if}
     {if $viewActURL}
     <tr>
       <td colspan="2" {$valueStyle}>
   <a href="{$viewActURL}" title="{ts}View activity{/ts}">{ts}View activity{/ts}</a>
       </td>
     </tr>
     {/if}
     {foreach from=$activity.fields item=field}
      <tr>
       <td {$labelStyle}>
        {$field.label}{if $field.category}({$field.category}){/if}
       </td>
       <td {$valueStyle}>
        {if $field.type eq 'Date'}
         {$field.value|crmDate:$config->dateformatDatetime}
        {else}
         {$field.value}
        {/if}
       </td>
      </tr>
     {/foreach}

     {foreach from=$activity.customGroups key=customGroupName item=customGroup}
      <tr>
       <th {$headerStyle}>
        {$customGroupName}
       </th>
      </tr>
      {foreach from=$customGroup item=field}
       <tr>
        <td {$labelStyle}>
         {$field.label}
        </td>
        <td {$valueStyle}>
         {if $field.type eq 'Date'}
          {$field.value|crmDate:$config->dateformatDatetime}
         {else}
          {$field.value}
         {/if}
        </td>
       </tr>
      {/foreach}
     {/foreach}
    </table>
   </td>
  </tr>
 </table>
</center>

</body>
</html>
1

You can edit the message template at admin - Civimail- message templates on the system workflow tab and use the api to look up the current user's info, as described at https://docs.civicrm.org/dev/en/latest/api/interfaces/#smarty-api-interface

e.g. {crmAPI entity='contact' action="get" ...

  • I think we're talking about different things. I would like to add a few more codes to the code above to add the phone and email address of the person I created the event to. – Fatih ATEŞ Jul 27 at 14:15
  • Seems like we are talking about the same thing. See here for another example of using smarty and crmapi to look up and add info in a message template civicrm.stackexchange.com/questions/29230/… – Demerit Jul 27 at 15:05
1

Fatith, As per your requirement this is not straight forward and needs some custom coding or need good knowledge about using smarty api since the created id is stored as source contact id for an activity and data of source contact id is directly not available in smarty or as a token.

Here is possible solution for this

  1. Create token and token values using CiviCRM hooks, then add tokens in message template

  2. Like @demerit said use smarty to get contact details of the person who created the activity. Below snippet should work in your case. You need to add the below code in desired place in message template.

snippet:

{if $contact.activity_id}
  {crmAPI var='activityResult' entity='Activity' action='getsingle' return="source_contact_id" id=$contact.activity_id}
  {crmAPI var='contactResult' entity='Contact' action='getsingle' return="phone,email" id=$activityResult.source_contact_id}
  <tr>
    <td>Phone Number</td>
    <td>{$contactResult.phone}</td>
  </tr>
  <tr>
    <td>Email</td>
    <td>{$contactResult.email}</td>
  </tr>
{/if}

HTH

Pradeep

  • Hello, Pradeep. Smarty civicrm.settings.php ('CIVICRM_MAIL_SMARTY', 1); I started doing it. Then I added the code you passed to the message patterns. The phone and email came, but the person who created the record came. The activity I wanted was for the new individual created. – Fatih ATEŞ Jul 29 at 6:00
  • And how this new individual is attached to activity? Assignee or target? – Pradeep Nayak Jul 29 at 8:30
  • Hi @pradeep-nayak I create an event with the steps "Create New> Individual> Actions> Phone Call". I would like to withdraw individual information from this event. When I add "Assigned to", I get the name and surname of the individual. I want the phone and E-mail information to come under it. I don't think this should be that hard. – Fatih ATEŞ Aug 1 at 6:09

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.