2

Is there an API call available which could automatically create address labels?

This could be very handy with CiviRules, to have an automatic API-action to create address labels overnight.

2
  • AFAIK civi rules gets triggered on a condition, do you want to print address label for all the contact automatically or after update to address or contact for a contact? – Pradeep Nayak May 6 at 9:37
  • I am interested in how the address label creation works, and if there is an action that could easily be used both by CiviRules and FormProcessor to create both single and batches of address labels – Flying May 8 at 18:03
0

It depends what you mean by "API". If it's a script you're going to run overnight you could do something like this and put it in a file, let's say labels.php:

<?php
$form = new CRM_Contact_Form_Task_Label();
// Array of contact ids - could get this from wherever.
$form->_contactIds = array(2,3,4);
$params = array(
  'label_name' => 3475,
  'location_type_id' => NULL,
  'do_not_mail' => 1,
);
$form->postProcess($params);

Then run the script with cv, e.g. cv scr --user=admin labels.php > output.pdf

Or some variation of that. There's some trickiness to capturing the output within the script if you didn't want to redirect to a file - you'd either have to duplicate a lot of code or rely on something that is internally used for unit tests and could disappear.

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.