New tools to automate the configuration and staging/production migration

Have you ever clicked a few zillion time on the admin interface to create a lot of groups, tags, values for a custom field... ?

Have you ever screamed having to do the same tedious tasks you did on the staging one more time on the production site?

Have you cursed the import wizard after having clicked again and again on the next button ?

Friends of the shell, rejoice, the API is there to the rescue and tech to the people has contributed a few simple tools. As of civicrm 3.4, we have introduced 3 scripts: bin/csv/export.php bin/csv/import.php and bin/csv/delete.php

They allow to import (create or update), export and delete any entity exposed by the API (almost everything).

The syntax is simple: the first line is the name of the fields all the others are entities. you can find the name of these fields using the getfields action on any entity from the API explorer

We have been using it for a while. Beside offering a faster tool to create or edit a lot of entities, that has been proven very convenient to migrate data between environments. And we are using it with git as a way of backuping and keeping an history of some key configuration elements and being able to restore/apply them on a more granuar basis than sql dumps.

We also have found it very convenient to configure civicase to create the needed relationships and activity types.

eg. to export all the activity types (and by importing OptionValue with the column option_group_id = 2 you will create/update them)

Next time you have batch actions, try using these API tools, you'll love it, and who knows, you might even find a new nice feature one of the api is missing and contribute back?

Why is that a shell tool? Isn't there a web interface too I can almost hear you asking?

Because the cli is a much more convenient tool to handle these batch tasks and deal much better with files that are a lot bigger (eg if you start exporting/importing loads of contacts). It's also made to be scripted, so for instance sending you by email weekly the organisations above is a trivial oneliner. Really, you should have a server that offers you a ssh access and spend the time to learn bash, at least for the basic stuff.

This being said, if enough of you are interested of having a web interface too, you can make it happen...

When checking the before / after copies of the Custom Group Table (and the export file) I noticed that the following fields had not been included in the export (and hence, the values in these fields could not be re-imported, and so were lost):