Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-16705

Cannot add pdf format to MessageTemplate through API

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.6.3
    • Fix Version/s: 4.7
    • Component/s: CiviCRM API
    • Labels:
      None
    • Documentation Required?:
      None
    • Funding Source:
      Core Team Funds

      Description

      When creating / updating a MessageTemplate throught the API. I cannot add the pdf_format_id through the api.

      To reproduce: create a pdf format id.
      Execute following api calls.

      Works:

      civicrm_api3('MessageTemplate', 'create', array(
          'msg_title' => 'Attest deelname',
          'msg_subject' => 'Bewijs van deelname',
          'msg_html' => $template_html,
          'is_active' => '1',
          'is_default' => '1',
          'is_sms' => '0',
        ));
      

      Does not work:

      civicrm_api3('MessageTemplate', 'create', array(
          'msg_title' => 'Attest deelname',
          'msg_subject' => 'Bewijs van deelname',
          'msg_html' => $template_html,
          'is_active' => '1',
          'is_default' => '1',
          'is_sms' => '0',
          'pdf_format_id' => ID-NUMBER
        ));
       '769' is not a valid option for field[error]
      pdf_format_id in civicrm_api3()
      

      Does not work:

      civicrm_api3('MessageTemplate', 'create', array(
          'msg_title' => 'Attest deelname',
          'msg_subject' => 'Bewijs van deelname',
          'msg_html' => $template_html,
          'is_active' => '1',
          'is_default' => '1',
          'is_sms' => '0',
          'pdf_format_id' => ID-NAME (which is what api explorer suggests). 
        ));
      

      Gives: "error_message":"pdf_format_id is not a valid integer"

      The last one is a 'correct' error message, but the api-explorer should add the pdfformat id, and not the name.

      I can work around this by doing this with a DB query, so i'm not sure i can find time to create a PR. Feel free to grab this

        Attachments

          Activity

            People

            • Assignee:
              colemanw Coleman Watts
              Reporter:
              mallezie Tim Mallezie
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: