2

Is there a way to set a default Template on the Print/Merge Document screen? I have a common workflow which uses a customised search, which then goes to the Print/Merge Document action (or a clone thereof) and I would like this to default to the correct template.

I have tried using Javascript to change the Select box, but it seems to have timing problems and sometimes the Template just does not appear.

With thanks, Tony

1

The timing issue is probably ckeditor hasn't finished loading yet so it can't fill in the message body. Is your javascript wrapped in .ready()?

Otherwise you could try using the buildForm() hook in an extension and look up the template html for that template and then call setDefaults()

$result = civicrm_api3('MessageTemplate', 'get', array(
  'id' => 66, // or whatever the id is
));

$form->setDefaults(
  array(
    'subject' => $results['values']['msg_subject'],
    'html_message' => $results['values']['msg_html'],
  )
);
  • Thank you. My JS is wrapped in .ready() and I have tried adding various other delays, with mixed success. I will definitely look at using the build(Form() hook though. – maynardsmith Jan 4 at 13:01

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.