CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 3.0 Release Testing »
  • Create PDF letter and tokens not working
Pages: [1]

Author Topic: Create PDF letter and tokens not working  (Read 5047 times)

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Create PDF letter and tokens not working
August 06, 2009, 08:19:32 am
The new create PDF letter option under more actions (which is great by the way), doesn't convert tokens. When you insert a token, ist simply inserts the name of the token, not the token. And when you generate the PDF, the token isn't replaced.

This was tested on sandbox.

Thanks
Tony
http://dharmatech.org
oss@dharmatech.org
801.541.8671

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Create PDF letter and tokens not working
August 06, 2009, 09:18:52 am
There were a few bugs in the original code re: tokens (this was a community contribution) that I had run into while implementing for a v2.2 installation. Here's the revised function in CRM/Mailing/BAO/Mailing.php. Haven't tested on v3.0 yet, but it looks like they just plugged it in from the original version, so this fix should work.

Code: [Select]
    public function commonLetterCompose ( &$form )
    {
        //get the tokens.
        $tokens = CRM_Core_SelectValues::contactTokens( );
        if ( CRM_Utils_System::getClassName( $form )  == 'CRM_Mailing_Form_Upload' ) {
            $tokens = array_merge( CRM_Core_SelectValues::mailingTokens( ), $tokens );
        }

        $form->add( 'select', 'token2',  ts( 'Insert Tokens' ),
                    $tokens , false,
                    array(
                          'size'     => "5",
                          'multiple' => true,
                          'onchange' => "return tokenReplText(this);"
                          )
                    );
       
        $form->add( 'select', 'token1',  ts( 'Insert Tokens' ),
                    $tokens , false,
                    array(
                          'size'     => "5",
                          'multiple' => true,
                          'onchange' => "return tokenReplHtml(this);"
                          )
                    );
       
        require_once 'CRM/Core/BAO/MessageTemplates.php';
        $form->_templates = CRM_Core_BAO_MessageTemplates::getMessageTemplates();
        if ( !empty( $form->_templates ) ) {
            $form->assign('templates', true);
            $form->add('select', 'template', ts('Select Template'),
                       array( '' => ts( '- select -' ) ) + $form->_templates, false,
                       array('onChange' => "selectValue( this.value );") );
            $form->add('checkbox','updateTemplate',ts('Update Template'), null);
        }
       
        $form->add('checkbox','saveTemplate',ts('Save As New Template'), null,false,
                          array( 'onclick' => "showSaveDetails(this);" ));
        $form->add('text','saveTemplateName',ts('Template Title'));
     
       
        //insert message Text by selecting "Select Template option"
        $form->add( 'textarea',
                    'text_message',
                    ts('Text Message'),
                    array('cols' => '80', 'rows' => '8',
                          'onkeyup' => "return verify(this)"));
        $form->addWysiwyg( 'html_message',
                           ts('HTML Message'),
                           array('cols' => '80', 'rows' => '8',
                                 'onkeyup' =>"return verify(this)" ) );
}
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Create PDF letter and tokens not working
August 06, 2009, 01:44:42 pm
Brian:

In v3.0 we need did some code clean up for this functionality. So it would be great if you can test it on sandbox :)

Kurund
Found this reply helpful? Support CiviCRM

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Create PDF letter and tokens not working
August 07, 2009, 10:59:44 am
Just did some testing.

The problem I had fixed in Al's original code is not the problem (I don't think). The problem is with the actual token insertion -- instead of inserting the token value, it inserts the token label. So if you select "Display Name" from the popup it inserts "Display Name" in the body of the textarea, where it should insert "{contact.display_name}"

I tested with manually inserting the token in the body and it does work. I also tested the email function and that works correctly -- inserting the token value. So something's goofed up with the token insert on the pdf letter form.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Create PDF letter and tokens not working
August 07, 2009, 02:08:30 pm
I checked on my local joomla install and also on sandbox, display token is replaced correctly. ie. {contact.display_name}

Kurund
Found this reply helpful? Support CiviCRM

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Create PDF letter and tokens not working
August 07, 2009, 02:29:34 pm
I just tested on the demo and it's not working. Here's how to reproduce:

1. Run a search.
2. Select all contacts
3. Select "create pdf letter from contacts"
4. Insert token

The token is inserted with the label, not the token text. See screenshot.
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

Kurund Jalmi

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4169
  • Karma: 128
    • CiviCRM
  • CiviCRM version: 4.x, future
  • CMS version: Drupal 7, Joomla 3.x
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Create PDF letter and tokens not working
August 07, 2009, 04:37:23 pm
Oh. sorry I was checking tokens for email and assumed it would work for pdf letter and I was worng. But now it is fixed and I have updated sandbox.

thanks,
Kurund
Found this reply helpful? Support CiviCRM

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Create PDF letter and tokens not working
August 10, 2009, 08:51:11 am
Thanks Brian and Kurund for helping on this.

Unfortunately, it's still not working on sandbox. I tried creating a letter for just one contact, Donald Adams, with basic tokens (first, last, address, city, state, zip) and the tokens now insert properly but are not converted upon PDF generation.

Attached is the PDF that was created.

Thanks
Tony
http://dharmatech.org
oss@dharmatech.org
801.541.8671

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Create PDF letter and tokens not working
August 11, 2009, 12:30:09 am
It looks like contact ( "Donald Adams" ) is deceased and we are respecting it.

hope it make sense.

kiran
You Are Designed To Choose... Defined By Choice.

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Re: Create PDF letter and tokens not working
August 11, 2009, 07:32:06 am
Oh ok. I see.  It's working now. I just used a bad example.

Thanks Kiran!

Tony
http://dharmatech.org
oss@dharmatech.org
801.541.8671

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Create PDF letter and tokens not working
August 11, 2009, 07:32:14 pm
I just tried this, and the tokens were still not working.  I selected three contacts, and opted for the "basic info" template.  See attached.


Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: Create PDF letter and tokens not working
August 11, 2009, 10:57:54 pm
make sure your selected contact should not be deceased.

can u try to replicate on : http://sandbox.civicrm.org/

If issue persists, give your list of sample contacts for which tokens are not replaced.

thanks
kiran
You Are Designed To Choose... Defined By Choice.

robinhood

  • I post frequently
  • ***
  • Posts: 153
  • Karma: 6
  • CiviCRM version: 4.5.5
  • CMS version: Drupal 7.34
  • MySQL version: 5.1.56
  • PHP version: 5.3.5
Re: Create PDF letter and tokens not working
August 12, 2009, 06:50:23 pm
Ha ha well this comes of having a bunch of contacts in the sandbox marked as deceased.  I have brought them back to life, so now they can get our letters.  I am sure they will be grateful.

 ;)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Discussion (deprecated) »
  • Alpha and Beta Release Testing »
  • 3.0 Release Testing »
  • Create PDF letter and tokens not working

This forum was archived on 2017-11-26.