Answers.Body: <p>Tracked this one down. It worked out of the box in 4.4.x, but doesn't in 4.5.x. Not sure whether it was deliberate, but it's pretty easy to 'fix'.</p>
  
  <p>Edit templates/CRM/Mailing/Form/InsertTokens.tpl and change:</p>
  
  <pre><code>  cj.post( dataUrl, {tid: val}, function( data ) {
      if ( !isPDF ) {
        if (prefix == "SMS") {
            text_message = "sms_text_message";
        }
        else {
          cj("#subject").val( data.subject );
        }
  </code></pre>
  
  <p>to:</p>
  
  <pre><code>  cj.post( dataUrl, {tid: val}, function( data ) {
      cj("#subject").val( data.subject );
      if ( !isPDF ) {
        if (prefix == "SMS") {
            text_message = "sms_text_message";
        }
  </code></pre>
  
  <p>It's explicitly only setting the Activity Subject for non-PDFs, which is weird. It looks like it was <a href="https://github.com/civicrm/civicrm-core/commit/1e035d58875c61cef9136fd8200dcef7fe591afe#diff-5990409ef24052bbfef770f424294b5cL151" rel="nofollow">accidentally(?) reverted</a> when SMS support for recurring contributions was being added. Have created <a href="https://issues.civicrm.org/jira/browse/CRM-16211" rel="nofollow">an issue</a>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-11T14:43:50.220Z
Answers.Text: Issue is now patched and closed - should be part of 4.6.1.
Answers.UserDisplayName: Andrew West
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-04-01T17:05:43.227Z
Answers.LastActivityDate: 2015-04-01T17:05:43.227Z
Answers.UserDisplayName: Andrew West
Answers.Body: <p>You may be able to use hook_civicrm_pre. But i'm not sure you have the template in this context.</p>
  
  <pre><code>function myextension_civicrm_pre( $op, $objectName, $id, &amp;$params ) {
    if ($op == 'create' &amp;&amp; $objectName == 'Activity') {
      // define PDFLETTER_ACTIVITY_ID or replace with the good id
      if ($objectRef-&gt;
      $params['activity_type_id'] == PDFLETTER_ACTIVITY_ID) {
        // 1. get the template (is it possible from there ?)      
        ...
  
        // 2. replace the title
        $params['subject'] = ...
      }
  
    }
  }
  </code></pre>
  
  <p>Otherwise you will have to use hook_civicrm_postProcess but it's more complex.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-03-31T16:28:32.133Z
Answers.LastActivityDate: 2015-03-31T16:28:32.133Z
Answers.UserDisplayName: samuelsov
Body: <p>Is it possible to automatically set the 'Activity Subject' of PDF letters to the 'Message Subject' of the selected template? I swear I've seen this done with a quick bit of code, but the keywords are escaping me...</p>
  
Tags: <templates><pdf>
Title: How to automatically set PDF 'Activity Subject' from template subject?
ThreadText: # How to automatically set PDF 'Activity Subject' from template subject?
  
  (Asked by: username_0 on 2015-03-31)
  
  Is it possible to automatically set the 'Activity Subject' of PDF letters to the 'Message Subject' of the selected template? I swear I've seen this done with a quick bit of code, but the keywords are escaping me...
  
  **Tags:** templates, pdf
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2015-04-01. Score: 4 | Accepted answer
  
  Tracked this one down. It worked out of the box in 4.4.x, but doesn't in 4.5.x. Not sure whether it was deliberate, but it's pretty easy to 'fix'.
  
  Edit templates/CRM/Mailing/Form/InsertTokens.tpl and change:
  
  ```
    cj.post( dataUrl, {tid: val}, function( data ) {
      if ( !isPDF ) {
        if (prefix == "SMS") {
            text_message = "sms_text_message";
        }
        else {
          cj("#subject").val( data.subject );
        }
  
  ```
  
  to:
  
  ```
    cj.post( dataUrl, {tid: val}, function( data ) {
      cj("#subject").val( data.subject );
      if ( !isPDF ) {
        if (prefix == "SMS") {
            text_message = "sms_text_message";
        }
  
  ```
  
  It's explicitly only setting the Activity Subject for non-PDFs, which is weird. It looks like it was [accidentally(?) reverted](https://github.com/civicrm/civicrm-core/commit/1e035d58875c61cef9136fd8200dcef7fe591afe#diff-5990409ef24052bbfef770f424294b5cL151) when SMS support for recurring contributions was being added. Have created [an issue](https://issues.civicrm.org/jira/browse/CRM-16211).
  
  > **Comments:**
  > **username_0**: Issue is now patched and closed - should be part of 4.6.1.  
  
  ---
  
  ### Answer by username_1 on 2015-03-31. Score: 1
  
  You may be able to use hook\_civicrm\_pre. But i'm not sure you have the template in this context.
  
  ```
  function myextension_civicrm_pre( $op, $objectName, $id, &$params ) {
    if ($op == 'create' && $objectName == 'Activity') {
      // define PDFLETTER_ACTIVITY_ID or replace with the good id
      if ($objectRef->
      $params['activity_type_id'] == PDFLETTER_ACTIVITY_ID) {
        // 1. get the template (is it possible from there ?)      
        ...
  
        // 2. replace the title
        $params['subject'] = ...
      }
  
    }
  }
  
  ```
  
  Otherwise you will have to use hook\_civicrm\_postProcess but it's more complex.
  
  
  ---
  
  