Altering CiviCRM data using Views Bulk Operations (Drupal)

It has been possible to make batch changes to CiviCRM data using VBO (Views Bulk Operations) for a while but I only just got around to implementing it for a customer so I am taking the chance to document what I did here!

The recipe is basically

- install civicrm_entity version 2.x & vbo

- create a View

- add and configure the desired 'bulk operation'

And, setting up a View with a bulk operation to modify Relationship End Dates was pretty much that easy

 

Install CiviCRM Entity version 2.x

  • https://www.drupal.org/project/civicrm_entity
  • note that by default you will get 1.x if you 'drush dl'
  • make sure you clear caches afterwards very thoroughly - especially if upgrading from 1.x
  • version 2.x includes a bunch of functionality around Display Suite contributed by Mark Hanna. It also exposes CiviCRM Entities as Content Types. I haven't explored all of this stuff fully

Create a View

  • Below is a shot of my resulting Views page display. This View was based on CiviCRM Relationships
  • Note the operation is visible here

Adding bulk operations

  • Bulk operations are added via the 'Add fields dialog' - choose a bulk operations option as in the picture
  • Set the Bulk operation to be 'modify entity values' and choose the 'properties' you want to be modifiable. You probably want to override the label too.

  • Save....

 

Here is how it looks when they fill it in

 

Cautions

It's not terribly clear what should be filled into those fields - ie. is active should be 0 or 1. It might be better to create a rules component to help your users in some cases.

 

Here is the feature in this example

https://github.com/eileenmcnaughton/feature_manage_relationships_vbo