Hot answers tagged

10

When you are importing a large number of contacts, you could face timeout issues when using the user interface. Importing through CLI is an alternative. There is a file called import.php in /civicrm/civicrm/bin/csv/import.php. We will call this file from the command line. After you have exported your CSV file, here are the steps for the import: Put the ...


5

One way of achieving your goal would be via a temporary group: Using advanced search, search for all contacts who do have a relationship (simply open the "Relationships" tab, enter nothing, and search - it will default to all active relationships). Add all the resulting contacts to a group (or make a smart group if you want to save yourself this step in the ...


5

If you're on Drupal and have drush installed you can do drush cvapi Contact.delete id=17 skip_undelete=1


4

Thing which works is "include/exclude custom search" : "Search -> Custom searches -> Include / Exclude Search" or /civicrm/contact/search/custom?csid=4&reset=1 Thanks @Coleman!


4

The CLI Contact import is meant to work on a per-entity basis, since it uses the API. So Contact is a separate entity from Address. The Contact entity API has a couple of hacks to accept certain parameters from other APIs - e.g. primary email address - but generally speaking, what you're doing is unsupported. If you'd like to do what you're doing via ...


4

On the command line, type php path/to/civicrm/bin/cli.php -e Contact -a delete --output --contact_id=17 (Note: passing a contact_id is mandatory when deleting. But you can delete multiple contacts by creating a php file that has a loop and executes the above command through exec().) If you want to permanently delete a contact, add the skip_undelete ...


4

Someone actually provided the answer to another person on the CiviCRM chat channel, so I'm posting it here: <juri_> "You have requested a non-existent service 'sql_triggers'." <juri_> anyone care to take a guess? this is civi on drupal 8. <mollux> juri_ clear the CiviCRM cache, had the same issue yesterday


3

The command cv (https://github.com/civicrm/cv) provides helpers for running PHP code via CLI. For example, to run a single line of PHP code, you might say: cd web-root cv ev 'CRM_Core_I18n_Schema::rebuildMultilingualSchema(array(...), NULL);' The snippet you posted involves a variable $locales which isn't defined here. If you know the intended content (e.g....


3

You can use drush cv to update the settings in db. eg drush cvapi Setting.create environment="Production" You can find various options in API explorer to set other settings and see for command in cv and drush section.


3

Another option is to use drush in combination with the combination with the cvapi command. For example drush cvapi Contact.create sequential=1 contact_type="Individual" first_name="Ben" middle_name="Lee" last_name="User" creates one contact. Specially useful when sometimes one contact must created by automatically by an unix script.


3

The command line import uses the default unsupervised rule for deducing. Out of the box that's just email. When using command line import if the unsupervised dedupe rule says the import line is a duplicate then it will do an update instead of a creating new record.


2

I found the problem. My csv file was on a staging server that required a user name and password for access. The error message was misleading, nothing wrong with the csv file. Once I put the file on the server in a place that is not password protected, it worked fine.


2

I think you probably will need to provide full path of php to execute php files. You can try the option from https://stackoverflow.com/questions/19916949/running-php-from-cron-did-not-run-as-cli/19917512#19917512 HTH Pradeep


2

Looks like a case for API chaining. This or something like it should work: drush cvapi OptionValue.getvalue return=id option_group_id=from_email_address \ api.OptionValue.create={label:'"Fixed" <info@fixed.org>'} Unfortunately, API chaining via drush does not appear to work. Thanks to @noah-miller for pointing that out. I tried chaining via cli....


2

In Civi 4.6+, you can use pseudoconstants instead of IDs in many places - including for option_group_id. Civi 4.7 expands the number of places you can use it. So you can get this down to 2 lines by replacing the first two with: OPTION_VALUE_ID=`drush cvapi OptionValue.getvalue return=id option_group_id=from_email_address`. Here's the trick: If the API ...


1

There are a few things that can help you out: Most importantly, the API Explorer (Support menu » Developer » API Explorer). It will build your drush command for you through a GUI. You can see there that adding an option with "limit=0" will return all records. There's documentation built into the API explorer, but there's also API documentation in the ...


1

The graphical api explorer actually fetches all its information about the api from the api. Since the CiviCRM api is available from the command line, you can explore it using the same methods. Fetch the list of entities: $ cv api Entity.get List available actions for an entity: $ cv api Activity.getactions Get fields for an entity/action: $ cv api ...


1

For those that use cv is also possible to use: echo '{"enable_components" :["CiviContribute","CiviMember","CiviMail","CiviReport","CiviEvent"] }' | cv api Setting.create --in=json


1

Thanks to passing JSON objects to drush cvapi I found a solution: echo '{"enable_components" :["CiviContribute","CiviMember","CiviMail","CiviReport","CiviEvent"] }' | drush cvapi Setting.create --in=json


1

if your user has cron access, you can always create a file, call it cron for simplicity sake, in the file add the command you wish to run, for example mine is a bit interesting cause I have to export my civicrm settings at the same time: export CIVICRM_SETTINGS="/home/domain/public_html/administrator/components/com_civicrm/civicrm.settings.php" cv api --...


1

I'm not sure about this but it sounds like a permissions problem and you may need to update the permissions in root/wp-content/plugins/civicrm/civicrm/bin/cli.php to be executable. Hope this solves your problem.


1

The reference for cli is Manage Scheduled Jobs. It tells This method requires a valid Username and Password (for a Drupal, Joomla or WordPress user who has adequate permissions for the job or jobs being run). So try to run it with a Wordpress user and password.


1

This cron job calls /etc/php.ini as the command, but that file is not an executable (it's the default configuration file for PHP). (The "Permission denied" error is the same as if you asked "run the script README.TXT" - the file doesn't have exec bit set because it's not a program at all.) Try this - 1 * * * * apache /usr/bin/php /var/www/example.org/...


1

Here's an example wp-cli command I use that works: /home/ubuntu/wp-cli/wp-cli --require=/home/ubuntu/wp-cli/civicrm.php --path=/var/www/wordpress civicrm api job.execute > /dev/null I hope that helps! UPDATE: I see your problem! "/path/to/wp" means, "path to wp-cli, including wp-cli". I completely looked past that part at the beginning, since that's ...


Only top voted, non community-wiki answers of a minimum length are eligible