4

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...

4

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 when SMS support for recurring contributions was being added. Have created an issue.

  • Issue is now patched and closed - should be part of 4.6.1. – Andrew West Apr 11 '15 at 14:43
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.

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.