# Question
Title: DB Error under Languages, Currency, Location
We need some help we using CiviCRM version 4.7.20 on Joomla version 3.7.2 and I try to set up the German languages, with no success: On **Administer – Localization – Languages, Currency, Location** this message appears:

**Sorry but we are not able to provide this at the moment.**

---

**DB Error: insufficient permissions Return to home page.**

Thanks in advance for your support.

```
#0 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(187): CRM_Core_Error::backtrace()
#1 /web/_crm/administrator/components/com_civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::handle(Object(DB_Error))
#2 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB.php(985): PEAR_Error->__construct("DB Error: insufficient permissions", -26, 16, (Array:2), "CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#3 /web/_crm/administrator/components/com_civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-26, 16, (Array:2), "CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#4 /web/_crm/administrator/components/com_civicrm/civicrm/packages/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -26, 16, (Array:2), "CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...", "DB_Error", TRUE)
#5 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))
#6 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-26, NULL, NULL, "CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...", "1142 ** TRIGGER command denied to user 'db12382598-user5'@'localhost' for tab...")
#7 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()
#8 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#9 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#10 /web/_crm/administrator/components/com_civicrm/civicrm/packages/DB/DataObject.php(1635): DB_DataObject->_query("CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#11 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(362): DB_DataObject->query("CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#12 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/DAO.php(1940): CRM_Core_DAO->query("CREATE TRIGGER civicrm_domain_trigger BEFORE INSERT ON civicrm_domain FOR EAC...")
#13 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Admin/Form/Setting/Localization.php(88): CRM_Core_DAO::checkTriggerViewPermission(TRUE)
#14 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Form.php(564): CRM_Admin_Form_Setting_Localization->buildQuickForm()
#15 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Display.php(92): CRM_Core_Form->buildForm()
#16 /web/_crm/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Admin_Form_Setting_Localization), "display")
#17 /web/_crm/administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Setting_Localization), "display")
#18 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("display")
#19 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Utils/Wrapper.php(113): CRM_Core_Controller->run()
#20 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(283): CRM_Utils_Wrapper->run("CRM_Admin_Form_Setting_Localization", "Languages, Currency, Locations", (Array:0))
#21 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))
#22 /web/_crm/administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:4))
#23 /web/_crm/administrator/components/com_civicrm/civicrm.php(121): CRM_Core_Invoke::invoke((Array:4))
#24 /web/_crm/administrator/components/com_civicrm/civicrm.php(40): civicrm_invoke()
#25 /web/_crm/libraries/cms/component/helper.php(394): require_once("/web/_crm/administrator/comp...")
#26 /web/_crm/libraries/cms/component/helper.php(369): JComponentHelper::executeComponent("/web/_crm/administrator/comp...")
#27 /web/_crm/libraries/cms/application/administrator.php(98): JComponentHelper::renderComponent("com_civicrm")
#28 /web/_crm/libraries/cms/application/administrator.php(156): JApplicationAdministrator->dispatch()
#29 /web/_crm/libraries/cms/application/cms.php(265): JApplicationAdministrator->doExecute()
#30 /web/_crm/administrator/index.php(51): JApplicationCms->execute()
#31 {main}

```

# Answer
The important part of the log is this:

```
TRIGGER command denied to user 'db12382598-user5'@'localhost'

```

You need to grant the TRIGGER permission to the MySQL user named above. Note that if you're on crappy shared hosting, you might not be allowed to use database triggers, which CiviCRM requires.

You can find more info here: CiviCRM MySQL Permission Requirements
> 2 votes

---
Tags: joomla, localisation
---


# Question
Title: What permission are required to select an existing event location in CiviEvent?
We are using CiviCRM 4.7.19 with Drupal 7.56. When creating or editing a CiviEvent our super users can use an existing location from a drop down:

We also use another role in our organisation with more limited permissions but still enables event add/edit. However in the Event Location tab while they can enter an address the 'Choose Location' block is not visible:

What permissions need to be set to allow the choose location block to be visible when editing/adding a CiviEvent? (We use Drupal Access Control to set permissions for CiviCRM)

# Answer
> 1 votes
If you're able edit an event, I don't think you need any additional permission to add existing location for an event.

The reason why you don't see an option could be because you haven't yet created any event location on this site? If this is the case, try adding a location for this event and then create a second event - you must be able to choose location on this newly created event.

---
Tags: civievent, permissions, acl
---


# Question
Title: Select alias with dot is not returned from CRM_Core_DAO::executeQuery()
I've been playing around with the idea of using the custom group and field name as an alias when fetching data using the API. Because of this I've ended up with a situation where an alias can have a dot in it.

This causes the aliased field to be returned as empty, whereas an alias without a dot in it will be fine.

`\CRM_Core_DAO::executeQuery('SELECT first_name as "Foo.Bar" FROM civicrm_contact;')->fetchAll()`

Will return an array of contacts, but with `Foo.Bar => ""`.

I've also tried using backticks around the alias, but with the same result.

I've found the cause of it, but am just posting this here for anyone else who might run into it.

# Answer
Depending on the version you're using you may have a different version of the pear DB\_DataObject, but they all seem to have something similar to this line:

`$kk = str_replace($replace, '_', $k);`

https://github.com/pear/DB\_DataObject/blob/trunk/DB/DataObject.php#L653

Which replaces dots and spaces in the keys of the results.

It seems like the steps it follows are:

* Call `fetchAll()` which loops through the results
* Call `fetch()` on each result. This will change the original keys, replacing any dots with underscores and store the value as a property using the changed key.
* Call `toArray()` to get the output for each result. `toArray()` will loop through the original keys and return an associative array, mapping the original keys to their value. However since the key used to store the value has changed the value will be empty.

I'm not sure why they do this, but if you want to avoid it you can either do some sort of hacky substitution on the select aliases before and after running the query.

Another alternative is to bypass any call to `DB_DataObject::fetch()`

```
  $results = array();
  $dbResult = \CRM_Core_DAO::executeQuery($sql)->getDatabaseResult();
  while ($row = mysqli_fetch_assoc($dbResult->result)) {
    $results[] = $row;
  }

```

Edit:

Normal usage of `SelectQuery::run()` gets around this by doing a string replace of `.` =\> `_` on the aliases and checking if a property existing in the BAO result.

https://github.com/civicrm/civicrm-core/blob/4c6cc3647eb7b19a05529bd40b02e26623e8effe/Civi/API/SelectQuery.php#L153

This should fix the problem, although in the later version of DB\_DataObject they're also replacing spaces, which would cause problems even if using `run()`.
> 2 votes

---
Tags: database
---


# Question
Title: CiviCase error "required params missing"
I'm getting a fatal error in the popup when trying to edit Case details (eg Type, Status) by clicking on the grey pencil in the contact summary. This has only happened since I moved the installation to a new server, with a more up-to-date version of MySQL and php (5.5.46 and 5.4.45). I have added all the db user privileges necessary for triggers.

Javascript console shows nothing, but the Civi log shows a fatal error ("required params missing") from CRM/Form/Activity.php, line 108. The full log is below.

That line 108 is the result of this test:

```
if (!$this->_caseId ||
      (!$this->_activityId && !$this->_activityTypeId)
    ) {
      CRM_Core_Error::fatal('required params missing.');
    }

```

Any ideas where I could look for a solution? I've spent a few hours on this so far - tried all Coleman's suggestions on this page, but nothing has made any difference at all - exactly the same error message. I even deleted all the cases, case types, activities and activiy types, as well as the corresponding entries in the option value table, but when I created a new case with new case type etc, still exactly the same error.

Thanks for any suggestions!

Jeremy.

Civi 4.6.10, Joomla 3.4.5

Backtrace of error in Civi log:

```
Dec 02 14:14:43  [info] $backTrace = #0 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Error.php(364): CRM_Core_Error::backtrace("backTrace", TRUE)
#1 ...path.../administrator/components/com_civicrm/civicrm/CRM/Case/Form/Activity.php(108): CRM_Core_Error::fatal("required params missing.")
#2 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Form.php(455): CRM_Case_Form_Activity->preProcess()
#3 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/QuickForm/Action/Display.php(94): CRM_Core_Form->buildForm()
#4 ...path.../administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Display->perform(Object(CRM_Case_Form_Activity), "display")
#5 ...path.../administrator/components/com_civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Case_Form_Activity), "display")
#6 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Controller.php(353): HTML_QuickForm_Page->handle("display")
#7 ...path.../administrator/components/com_civicrm/civicrm/CRM/Utils/Wrapper.php(115): CRM_Core_Controller->run()
#8 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(286): CRM_Utils_Wrapper->run("CRM_Case_Form_Activity", "Case Activity", NULL)
#9 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem((Array:14))
#10 ...path.../administrator/components/com_civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke((Array:3))
#11 ...path.../administrator/components/com_civicrm/civicrm.php(116): CRM_Core_Invoke::invoke((Array:3))
#12 ...path.../administrator/components/com_civicrm/civicrm.php(40): civicrm_invoke()
#13 ...path.../libraries/cms/component/helper.php(392): require_once("...path.../httpdocs/administrator/components/com_civicrm/civicrm...")
#14 ...path.../libraries/cms/component/helper.php(372): JComponentHelper::executeComponent("...path.../administrator/components/com_civicrm/civicrm...")
#15 ...path.../libraries/cms/application/administrator.php(98): JComponentHelper::renderComponent("com_civicrm")
#16 ...path...s/libraries/cms/application/administrator.php(152): JApplicationAdministrator->dispatch()
#17 ...path.../libraries/cms/application/cms.php(252): JApplicationAdministrator->doExecute()
#18 ...path.../administrator/index.php(47): JApplicationCms->execute()
#19 {main}

```

Result of calling a new tab:

An error has occurred

`0

 Sorry but we are not able to provide this at the moment.
required params missing.

Return to home page.

 `

# Answer
If you right-click on the pencil icon and then "copy shortcut" or "link location" or something like that, what does it look like? Specifically is there anything that has an = but with no value after it? e.g. it should look something like this http://joomla.demo.civicrm.org/administrator/?option=com\_civicrm&task=civicrm/case/activity&action=add&reset=1&cid=8&caseid=1&selectedChild=activity&atype=16

If that doesn't help then could narrow it down by editing that line 108 you mention. Change the CRM\_Core\_Error::fatal to something like this:

```
CRM_Core_Error::fatal("CaseId: {$this->_caseId}, Activity Type: {$this->_activityTypeId}, Activity Id: {$this->_activityId}");

```

It's unlikely to be case id, and the activity id is going to be blank if it's a new activity, so it might be the activity type. Make sure your database contains the proper values in the "name" column in civicrm\_option\_value, e.g.

```
SELECT * FROM civicrm_option_value WHERE name='Change Case Status';

```

If that comes up empty then the activity type is missing or misconfigured. You said you deleted entries in civicrm\_option\_value, so it may be hard to tell if it was there before or not.
> 0 votes

# Answer
Open the link in new tab instead of pop-up. You will get error in detail. Also check the browser console.
> 0 votes

# Answer
I was also stumbling on this issue, but it was happening only 1 or 2 times per day (on a rather active CiviCRM instance). Users were complaining that it happened when they left the tab open for an hour or more. There wasn't any other pattern.

Turns out it was the "cleanup" scheduled job that happens every hour. For now, I changed the job to "daily", but I will try to debug and file a bug report, if necessary (I'll update this post if I do).

Edit: I changed the Scheduled Job parameters to add: `session=0`.
> 0 votes

---
Tags: civicase, error, javascript
---


# Question
Title: Creating a copy of CiviCRM on a test sub-domain (Wordpress)
I need simple step-by-step procedure to copy my current production site to a sub-domain on the same server, that we intend using for testing/development (its important that we retain all our custom fields and other customization). We are running Wordpress, CiviCRM 4.7.12.

# Answer
Please refer to Moving an Existing Installation to a New Server or Location for this.
> 2 votes

---
Tags: testing
---


title: Addition of custom-fields

text:
# Question
Title: Addition of custom-fields
I would like to know if it is possible to customize the description of the contacts or any objects of the system? Can we enrich dropdown lists? Can we add fields and indicate it's a text, a date, a decimal, a booelan etc... Can we reorganise the tabs layout and mix standard fields and customized fields as we want?

Thank you for your answer Regards Evelyne PLEE-LEMOYNE

# Answer
Thank you for your interest in CiviCRM. Broadly, the answer to your question is 'YES'.

Since CiviCRM is open source software it is possible to customise anything and everything. However, some things are much easier to customise than others.

For example you can easily make changes to the configuration to do the following:

Other changes may require custom coding and so may require a developer to make the change for you (or you could learn how to do this yourself if you are that way inclined).

If you have specific questions about any of these topics it would be best to post them as separate questions. As mickadoo says StackExchange works best if you just ask one question per 'question'.
> 2 votes

---
Tags: custom-fields
---


# Question
Title: Permission errors when embedding civi-event on home page
I've used the shortcode to embed a test event on our home page.

But when the page loads I now get:

> "Sorry but we are not able to provide this at the moment. You do not have permission to access this page. Return to home page."

If I'm logged into the site I have no problem. And if I remove the event code it also works. Can you tell me how I can set permissions for guest users of the site?

# Answer
> 1 votes
You should take a look at the permissions of the CMS CiviCRM runs on (e.g. Drupal). You need to grant anonymous users the permission to "register for events" and probably also "view event info".

Maybe you could also add your CiviCRM version as well as the one of your CMS.

---
Tags: civievent, error, permissions, registration
---


# Question
Title: get source table values in civicrm_triggerInfo
I have created below hook for trigger some values in my table.

Here how to get source table values that are being updated or inserted

```
function history_civicrm_triggerInfo(&$info, $tableName) {
  $sourceTable = 'civicrm_membership_log';

  $sql = "
    INSERT INTO `civicrm`.`civicrm_membershipperiod`
(`id`, `membership_id`, `start_date`, `end_date`) VALUES (NULL, '1', '2017-07-03', '2018-07-03');";

  $info[] = array(
      'table' => $sourceTable,
      'when' => 'AFTER',
      'event' => 'INSERT',
      'sql' => $sql,
  );
  $info[] = array(
      'table' => $sourceTable,
      'when' => 'AFTER',
      'event' => 'UPDATE',
      'sql' => $sql,
  );
}

```

Based on the source table value I have to rewrite the query `$sql`

# Answer
> 1 votes
I'm not familiar with this hook, but the manual seems to suggest that `OLD.column_name` and `NEW.column_name` can be used to access old and new values respectively.

---
Tags: hooks
---


# Question
Title: Can't find a patch for "CiviCRM is not of type Int"
CiviCRM 4.6.4/Wordpress.

During API call for Contribution get and parameter id = xxxx, api returns `A fatal error was triggered: CiviCRM is not of the type Int`.

Adding a return statement in `wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php` solves the issue but unsure if this will affect other Contribution tasks in production..

Also tried a clean install of 4.6.4 on Wordpress and same issue.

See Line 266:

```
{
"trace": "#0 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/Type.php(269): CRM_Core_Error::fatal('CiviCRM is not ...')\n#1 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(5238): CRM_Utils_Type::escape('CiviCRM', 'Int')\n#2 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(373): CRM_Contact_BAO_Query::buildClause('civicrm_contrib...', '=', 'CiviCRM', 'Int')\n#3 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contribute/BAO/Query.php(251): CRM_Contribute_BAO_Query::whereClauseSingle(Array, Object(CRM_Contact_BAO_Query))\n#4 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Component.php(298): CRM_Contribute_BAO_Query::where(Object(CRM_Contact_BAO_Query))\n#5 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(1894): CRM_Core_Component::alterQuery(Object(CRM_Contact_BAO_Query), 'where')\n#6 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(499): CRM_Contact_BAO_Query->whereClause()\n#7 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Contact/BAO/Query.php(461): CRM_Contact_BAO_Query->initialize()\n#8 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/utils.php(595): CRM_Contact_BAO_Query->__construct(Array, Array, NULL, false, false, 2, false)\n#9 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/v3/Contribution.php(217): _civicrm_api3_get_query_object(Array, 2, 'Contribution')\n#10 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Provider/MagicFunctionProvider.php(89): civicrm_api3_contribution_get(Array)\n#11 /vagrant/donate/wp-content/plugins/civicrm/civicrm/Civi/API/Kernel.php(96): Civi\\API\\Provider\\MagicFunctionProvider->invoke(Array)\n#12 /vagrant/donate/wp-content/plugins/civicrm/civicrm/api/api.php(23): Civi\\API\\Kernel->run('Contribution', 'get', Array, NULL)\n#13 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(404): civicrm_api('Contribution', 'get', Array)\n#14 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Utils/REST.php(640): CRM_Utils_REST::process(Array, Array)\n#15 [internal function]: CRM_Utils_REST::ajax()\n#16 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(278): call_user_func(Array)\n#17 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(86): CRM_Core_Invoke::runItem(Array)\n#18 /vagrant/donate/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(54): CRM_Core_Invoke::_invoke(Array)\n#19 /vagrant/donate/wp-content/plugins/civicrm/civicrm.php(1188): CRM_Core_Invoke::invoke(Array)\n#20 [internal function]: CiviCRM_For_WordPress->invoke('')\n#21 /vagrant/donate/wp-includes/class-wp-hook.php(298): call_user_func_array(Array, Array)\n#22 /vagrant/donate/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array)\n#23 /vagrant/donate/wp-includes/plugin.php(453): WP_Hook->do_action(Array)\n#24 /vagrant/donate/wp-admin/admin.php(222): do_action('toplevel_page_C...')\n#25 {main}",
"is_error": 1,
"error_message": "A fatal error was triggered: CiviCRM is not of the type Int"
}

```

The code

```
CRM.api3('Contribution', 'get', {
  "debug": 1,
  "sequential": 1
}).done(function(result) {
  // do something
});

```

# Answer
> 1 votes
I remember this bug from a long time ago. I'm pretty positive it's been fixed.

I would try upgrading a copy of your site to the latest 4.6 to see if the problem still exists. If it doesn't, then upgrading is your solution.

# Answer
> 0 votes
This is definitely a bug in CiviCRM. I was able to duplicate it using the API Explorer in the 4.6.29 sandbox.

I note that the 4.7.x version sandbox did not take this error. You should consider updating your version to that.

I did a quick search in CiviCRM's JIRA but could not see such an issue reported.

---
Tags: issues
---


# Question
Title: Spanish protection of data obey. Question about a possible Sue against your company
I am really worried about the Spanish law of data protection. I would like to know if you have applied a special plan to obey this law. Thank you

# Answer
> 1 votes
Is this the same as the EU data protection directive? The good news is that it doesn't go in to force until mid-2018, so you've got a bit of time to figure it out.

# Answer
> 1 votes
I think this is more about hosting and configuration of your infrastructure than about the functionality of CiviCRM?

---
Tags: user-interface
---


# Question
Title: configuring SMTP on windows 7 for Civicrm
I am running CiviCRM 4.7.20 on Windows 7, Wordpress. CiviCRM will be accessible only in our LAN network. Want to use the mail functionalities. Got stuck with the email configuration. Bit confused with the steps. I need to send emails to my contacts from 1. Gmail 2. My institute's email addresses.

Is SMTP necessary? If yes how to proceed? If no, what other options?

New to Web technology. Any help would be appreciated. Little better explanation than help docs is needed

Thanks, Partha

# Answer
If you want CiviCRM to send email, you'll need a means of delivering them! SMTP is the internet protocol for doing this. Unlike Linux, Windows does not typically include an SMTP service out of the box. That's OK - you probably want to outsource that task to a provider!

* Since you're coming from a LAN, it may be that your internet provider offers an SMTP server you may use. This would be suitable for limited mail use, but **not suitable for large mailouts**. Consult with your ISP to understand their usage policy.
* You mention you're on a LAN at an institute. It's possible your institute provides an SMTP service already - your IT support (assuming you aren't the IT support yourself!) may be able to help.
* Dedicated SMTP providers (Wiki listing) are your next option.
    + Some of these offer a **free tier** (see my comment below). Free service may have some other cost associated, so choose a provider that you trust (they will be delivering your mail!) and can rely on.
    + Some of these providers will **require a plugin** to work well with CiviCRM.
* It's possible to use some "regular" mail providers (Google Apps and similar providers) as an SMTP service. Unless this is a development or test instance, I would **not recommend this**. (Basically, if you depend on the mails being delivered quickly, choose a dedicated service from those above and pay a few bucks.)
* Since you're hosting on Windows, you can't use `mail()` or `sendmail` options without installing a local Message Transfer Agent (MTA). This **probably isn't the right option** for you; choose this only if you have experience with managing internet-facing mail servers.
> 2 votes

---
Tags: civimail, email, mailing, configuration, settings
---


# Question
Title: How can you set webform to create a new relationship rather than update an expired relationship when the relationship type and person is the same?
Using webform to create relationships in CiviCRM. If contact 1 already has a existing relationship of the correct type to contact 2 even if it is expired it will update that relationship.

We would like to track when they had a relationship to X. Is there a way we can enter the relationship information through a webform and have it create a new relationship with X rather than updating their previous relationship to X?

We are using Drupal 7, CiviCRM 4.7 (also happening on 4.6.25) webform\_civicrm 7.x-4.16

# Answer
> 1 votes
This has been resolved in https://github.com/colemanw/webform\_civicrm/pull/75

This PR provides a field on the Additional options tab under CiviCRM on your webform so you can set it on a per webform basis. If you check the box then if there is an existing relationship of the same type with the other contact then it will create a new relationship record with the new start date rather than updating the old one.

# Answer
> 0 votes
There was previously a discussion about this on the module's issue tracker. And I agree in principle that it would be good to allow this. Although there may be some disagreement from anyone who favors the current behavior.

---
Tags: webform-civicrm, relationships
---


# Question
Title: Participant quantity passed to Additional Participant pages
On an event registration form I need to tailor a Price Set field (ticket type) for all participant pages, based on what is selected in the Participant count on the first page.

This is doable on the first page (buyer) in a Register.extra.tpl file because the participant count field is visible on that page so the form data is accessible in JQuery, but how do we interrogate the Participant count value for all subsequent Additional Participant pages please?

# Answer
> 0 votes
I don't know if this can answer your question, but :

If you are based upon Drupal and use Webform Integration, you can, in a webform, register several participants and build conditionnals between any fields of the webform, thus set any field value (e.g. Price) depending upon any other fields values (e.g. participant count).

---
Tags: civievent, developer, online-registration
---


# Question
Title: PayPal Website Payments Pro: This transaction cannot be processed. The merchant's account is not able to process transactions
We are getting the following PayPal error when trying to process a direct credit card payment via the PayPal Website payments processor on our event page:

> **10549 This transaction cannot be processed. The merchant's account is not able to process transactions.**
>
> The merchant account attempting the transaction is not able to process Direct Payment transactions. Contact PayPal for more information.

We do have a business account, so that can't be it. Am I correct in assuming that this is because this processor no longer works with current PayPal accounts? Do we need a legacy PayPal account? Or is there something else going on?

We are on Wordpress/CiviCRM 4.7.7

# Answer
> 1 votes
The ability to do a Direct Payment transaction is what you get with PayPal Pro, as I understand it (i.e. allows you to host the payment page on CiviCRM).

But you do likely want to update to the latest 4.7.x, I have heard of issues with PayPal, though not this drastic.

# Answer
> 1 votes
I had discovered, quite accidentally, that there are 2 "versions" of paypal website payments pro. There's the "old" version, which they don't tell you about, and the "new" version which they're rolling out by default on all new accounts. The "old" version, as I've learned, is the one that's compatible with the current version of CiviCRM (as of 4.7.19+) and if you want to be able to support recurring donations, you have to add the "DPRP" feature (Direct Payments Recurring Payments) which costs more.

They way I discovered this was when my org implemented a new account for a non-profit and the recurring donations kept failing. Upon weeks of troubleshooting with the paypal tech implementation team, we discovered that the issue was that the account type was all wrong and there's no way to revert to the older version, you would have to create a new account.

That said, I came here looking for a solution to this issue altogether, since I think it's somewhat odd that CiviCRM hasn't updated their integration with PayPal's latest APIs.....even though paypal currently supports the existing integration, you have to make sure to ASK for it when you upgrade to the business account.

I'd love it if someone from the Civi team could maybe add some color or background to this? I haven't found a lot of info on the interwebs.....

---
Tags: paypal
---


# Question
Title: Silent error when accessing php API has not logged in user
I'm having a strange problem using the CRM API thru PhP (i.e. not REST or AJAX). I'm trying to build a donations counter which tracks the total amount of contributions made under a specific contribution source. Everything works when I'm logged in. But when I'm not, I get a silent php error and my theme breaks. The only thing I can guess is that it might be related to user permissions. So I gave not logged in users the ability to Access CiviCRM and View Contributions. I can confirm this works using the dashboard. But I still cant get the API calls to work without breaking the site.

Things I have tried:

* Adding `'check_permissions' => false` to the call
* Surrounding the calls in a try / catch block
* Switching user context in d7 to the root user and then back again.

Maybe it's not even a permissions problem after all..?

CiviCRM version is 4.7 with Drupal 7.

# Answer
> 6 votes
The recommended way to include the necessary files to run the php API is to call civicrm\_initialize() before the API call.

# Answer
> 0 votes
If anyone else has this issue, it turns out that the CiviCRM module is not always loaded for not logged in users. Manually including the CRM API file fixed the problem:

```
    define('DRUPAL_ROOT', '/buildkit/build/CiviCRM');
    define('CIVI_ROOT', DRUPAL_ROOT . '/sites/all/modules/civicrm');
    define('API_PATH', CIVI_ROOT . '/api/api.php');

    /* Bootstrap into the Civi environment */
    require_once API_PATH;
    require_once CIVI_ROOT . '/civicrm.config.php';

```

---
Tags: api, permissions
---


# Question
Title: Is there an introduction to CiviCRM Entity anywhere?
After a year or two of occasionally trying to utilize CiviCRM Entity, I am no closer to understanding the module.

I've read every bit of documentation that I can find, which mostly pertain to Rules (which I try to use sparingly).

What I'd really love to see is an example of how to use it to create content types if that is possible (I have no idea!).

With as much as I try to integrate Civi and Drupal I am missing this golden goose!

Any suggestions?

# Answer
I found the best introduction was this workshop: https://denver2015.civicrm.org/sessions/civicrmdrupal-integration-showcase The PDF on that page is helpful; the video of the workshop is available here: https://www.youtube.com/watch?v=i2GpnrVGdrc.

Note also that there are significant plans underway for CiviCRM Entity announced this week, see here: https://www.drupal.org/node/2676756
> 4 votes

# Answer
We are actually working on official CiviCRM Entity documentation now, but its not quite ready yet.

Until then you can review our blog articles with the CiviCRM Entity tag to learn more about specific features and updates to the module.

https://skvare.com/tags/civicrm-entity
> 1 votes

---
Tags: drupal, civicrm-entity
---


title: Country ISO and World region in Views

text:
# Question
Title: Country ISO and World region in Views
There is no Views relationship to civicrm\_country nor civicrm\_worldregions. How to create a view counting number of contacts from a region?

# Answer
> 3 votes
As of CiviCRM Entity 2.0-beta8 the Views relationships to Country and World Region have been made available. You must install the CiviCRM Entity Views Extras submodule.

CiviCRM Entity can be downloaded here: https://www.drupal.org/project/civicrm\_entity

---
Tags: drupal, drupal-views, 4.6
---


title: How to handle conditions in API

text:
# Question
Title: How to handle conditions in API
I have created a API. In this a simple select query is running and data is displaying as JSON format

But I don't how to handle / pass all the conditions to the select query

Parameter = 1 or Parameter \<= 1 or Parameter =\> 1 or Parameter != 1 or,...

Currently my query is as below

```
Select col1,col2,col3 from civicrm_table

```

I want to build my select query as

```
Select col1,col2,col3 from civicrm_table where condition

```

Here condition may be any one from the list

Is there a simplest way to handle this in Civi API

**My API code**

```
<?php

/**
 * Membershipperiod.Get API specification (optional)
 * This is used for documentation and validation.
 *
 * @param array $spec description of fields supported by this API call
 * @return void
 * @see http://wiki.civicrm.org/confluence/display/CRMDOC/API+Architecture+Standards
 */
function _civicrm_api3_membershipperiod_Get_spec(&$spec) {
//  $spec['magicword2']['api.required'] = 1;
  $spec['membership_id']['api.required'] = 1;
}

/**
 * Membershipperiod.Get API
 *
 * @param array $params
 * @return array API result descriptor
 * @see civicrm_api3_create_success
 * @see civicrm_api3_create_error
 * @throws API_Exception
 */
function civicrm_api3_membershipperiod_Get($params) {

$condition="";
if($params['membership_id'])
{
  if(is_array($params['membership_id']))
    {
    foreach($params['membership_id'] as  $key=>$val)
         $val="p.membership_id $key $val";
    }
else
$val="p.membership_id=".$params['membership_id'];
$condition=" and $val";
}

  $query = "SELECT c1.display_name, m.contact_id, c.total_amount,p.membership_id
FROM civicrm_membership m
RIGHT JOIN civicrm_membership_payment p ON m.id = p.membership_id
INNER JOIN civicrm_contribution c ON c.id = p.contribution_id
INNER JOIN civicrm_contact c1 ON c1.id = m.contact_id $condition";

  $result_array=array();
//    $result_array[]=$params['membership_id'];
  $dao = CRM_Core_DAO::executeQuery($query);
  while ($dao->fetch()) {
    $display_name=$dao->display_name;
    $contact_id=$dao->contact_id;
    $total_amount=$dao->total_amount;
    $membership_id=$dao->membership_id;

    $result_array[]=array("contact_id" => $contact_id,"membership_id" =>$membership_id, "name" => $display_name, "amount_paid" => $total_amount);
   }

$returnValues=$result_array;
    // Spec: civicrm_api3_create_success($values = 1, $params = array(), $entity = NULL, $action = NULL)
    return civicrm_api3_create_success($returnValues, $params, 'NewEntity', 'NewAction');

}
?>

```

**BAO**

```
class CRM_History_BAO_MembershipPeriod extends CRM_History_DAO_MembershipPeriod {

  /**
   * Create a new MembershipPeriod based on array-data
   *
   * @param array $params key-value pairs
   * @return CRM_History_DAO_MembershipPeriod|NULL
   *
  public static function create($params) {
    $className = 'CRM_History_DAO_MembershipPeriod';
    $entityName = 'MembershipPeriod';
    $hook = empty($params['id']) ? 'create' : 'edit';

    CRM_Utils_Hook::pre($hook, $entityName, CRM_Utils_Array::value('id', $params), $params);
    $instance = new $className();
    $instance->copyValues($params);
    $instance->save();
    CRM_Utils_Hook::post($hook, $entityName, $instance->id, $instance);

    return $instance;
  } */

}

```

# Answer
> 2 votes
It looks like you pretty much have it almost done from your screenshot. The where conditions are in the parameters, you have membership\_id selected, and you can choose an operator and value for each of the parameters.

Regarding the `SELECT col1, col2, col3`, if you want to limit to only certain fields you can do that with the "Fields to return" box.

---
Tags: api, webform-civicrm
---


title: How can we see change logs for events?

text:
# Question
Title: How can we see change logs for events?
We are using Civi 4.7.13 with logging enabled. How can we access the logs specifically for events to see the user change history, when an event was deleted and possibly what changed?

# Answer
I don't think you can get the logs for Events via the UI. If you have access to the db then most tables have a log table, eg log\_civicrm\_event and log\_civicrm\_participant
> 1 votes

---
Tags: civievent, logging
---


# Question
Title: Is there a customized realtor sales and contact management system in civi
Is there a customized realtor sales and property management and contact prospecting system available for CiviCRM, eg through an extension or set of modules integrating with Drupal?

# Answer
CiviCRM can be customized by developers and implementers to suit a wide variety of needs. It may or may not do what you need out of the box, but one of the CiviCRM Partner companies could help you out.

CiviCRM is the best open source CRM going and when used with a CMS like Drupal can be quite extensible and powerful.
> 4 votes

# Answer
No. CiviCRM is designed for use by nonprofits and community organizations. Most of these groups don't substantially deal in sales, so little functionality to address this space has been developed.
> 2 votes

# Answer
I think that with CiviCase and other Activities and using Drupal Views and Webforms you could build a system to track leads and sale process quite well. While CiviCRM was designed for non-profits it is very adaptable and is used in a huge range of contexts. The flexibility of Activities and Case management provides great potential for such use cases.
> 1 votes

---
Tags: drupal, evaluating-civicrm
---


title: Creating a donor letter

text:
# Question
Title: Creating a donor letter
We are trying to find out if we enter a contribution in a donor record, are you able to create a donor letter from a constituent record in CiviCRM?

# Answer
> 2 votes
welcome to civicrm stackexchange.

You can generate receipts as PDF files to then print and post. You can do this via the Contact's 'contribution' record or via Find Contributions eg at

http://dmaster.demo.civicrm.org/civicrm/contribute/search?reset=1

if you tick a Contribution, then under Actions you can see both

* Receipts - Print or Email
* Thank you letters - Print or Email.

Pls add comments below, or embellish your question with more details if this doesn't answer your question.

You can read more about this in the Documentation

Also, in terms of StackExchange protocol, if an Answer is helpful, give it a +1, and if it gives you the Answer you need (ie you might get several answers) then 'accept' it.

---
Tags: civicontribute
---


# Question
Title: Missing indices error followed by missing system status page
Trying to implement the solution that worked when I got the missing indices error after the 4.7.20 update, but can't hit the Update button because System Status page isn't populating with anything. Haven't found a cause or solution for the empty System Status page. So I'm running 4.7.21 -- presumably with the missing indices error, and no way to fix it.

Suggestions?

# Answer
> 2 votes
This sounds similar to Status page angular load error and i will paste my answer here, though I think your 'question' is the wrong issue, ie this is angular issue, not missing indices issue.

We had one site that had 'lost' all it angular pages, eg CiviMail and System Status.

In our case the angular cache files were returning 404 on the New Mailing page. (and 'inspector' was showing a lot of red angular errors)

It was building the cache files in sites/default/files/civicrm/images, but then searching for them in sites/default/files/civicrm/persist/contribute

The issue here was a mismatch between the resource url setting for Image Upload URL and the directory setting for Image Directory. Strangely (!!) these folders are being used for caching of angular files.

---
Tags: missing
---


# Question
Title: How do I download duplicates of imported contacts in the past month?
I import contacts almost every day, and I automatically press "skip" on the "For Duplicate Contacts" import option.

When the import is complete, I recognize that I have the ability to download the duplicate emails.

However, I have NOT been doing that.

So now, I want to download all of the duplicates emails in the month of June.

So is there any way to retrieve all of the duplicate contacts from June?

I'm using CiviCRM 4.7.16.

# Answer
I'm afraid those are gone. By definition, those items aren't saved anywhere.
> 1 votes

# Answer
EDIT - i realise i misread this totally. So you 'skip' and therefore don't know who was a Duplicate if you don't grab the files? Aren't these 'Duplicates' recorded in files in sites/default/files/civicrm/upload? That is where we go to find import files and import error files if we have to dig them out
> 0 votes

---
Tags: import, duplicate-contacts
---


# Question
Title: Civimail open tracking is not working for some mailings - inserts var/www/html into path for some mailings but not others
Civimail is inserting a path for the open tracking image that includes var/www/html

example where it does not work https://(domain.org)/var/www/html/sites/all/modules/civicrm/extern/open.php?q=nnnn

for some mailings the path is correct: https://(domain.org)/sites/all/modules/civicrm/extern/open.php?q=nnnn

The tracking works when I manually remove the var/www/html from the path for a given url and the open report shows the open

There have been no changes to the default directory or resource paths.

Anyone else see this behavior? It seems to have started in November (2016) but is inconsistent. Any suggestions on where to look?

# Answer
A workaround is to change the root civicrm token to an absolute path (Credit due to Eli Lisseck for research and workaround solution)

Under Resource URLs, change CiviCRM Resource URL from \[civicrm.root\]/ to sites/all/modules/civicrm/

(Note that civicrm.settings.php has the following setting for sites that work correctly and sites that do not work correctly. $civicrm\_root = '/var/www/html/sites/all/modules/civicrm';)

So, while this appears to be a workaround, it is hiding the "root" problem.
> 3 votes

---
Tags: civimail
---


# Question
Title: Why is the CiviCRM installer unable to connect to the MySQL server?
I am using Drupal 7.56 and CiviCRM 4.7.21 on Ubuntu 16.04. The Apache and MySQL servers run on the same host.

The Drupal and CiviCRM databases are stored on the same server, and are accessed with a single user. Drupal is happy and works just fine. But CiviCRM, using the same user as Drupal, cannot connect to the database.

The error message appears under the headings "CiviCRM Database Details" and "Drupal Database Details", in the following row:

```
Are the access credentials correct? | That username/password doesn't work:

```

Here's what I've done so far

* I have triple checked that I am not making any typos.
* I have verified that I can log into the MySQL account using the MySQL shell.
* I have verified that MySQL is listening on the default port.
* I have verified that MySQL is binding to 127.0.0.1.
* I have verified that there is no firewall in the way.
* I have tried out opening the server to remote connections and making the MySQL user able to log in remotely. I successfully connected with Sequel Pro, but CiviCRM didn't budge. I closed things down again.

I am a loss for what else I can try. Is there something special about how CiviCRM connects to MySQL? After all, Drupal is having no problems.

I notice that the error message ends with a colon, which implies that there is supposed to be some additional information. Does this imply that there may be a bug?

Thanks very much!

# Answer
In my experience if 'localhost' (or your host) was refusing to connect on default port with all credentials/permissions definitely correct, specifying 'localhost:3306' will work (even though you shouldn't have to specify the :3306, and I think it tells you as much).

I will also note that this is something I have only experienced recently, and with this question there are examples on Ubuntu, and in my case MAMP.
> 2 votes

---
Tags: drupal, database, installation, mysql, authentication
---


# Question
Title: Why does a user get 'email field required' after submitting a form such as a Contribution page
If a Contribution page has a profile that creates a Drupal User, then the user gets a message after submitting the form that 'email is required' and no Drupal user is created.

Not sure if this is only affecting Drupal.

# Answer
Looks to me like to me like this was a problem in 4.7.20 and 4.7.21 and am picking this JIRA issue is involved and have created this JIRA issue for the fix.
> 2 votes

---
Tags: drupal, profile, contribution-page, user-account
---


# Question
Title: How can I fix this problem with duplicate index in 4.7.21?
Upgraded from 4.7.17 to 4.7.21 and got the following message that I don't know how to fix. I don't have drush and the other answers to this problem don't include this index or don't fix this particular problem. I tried "ALTER TABLE civicrm\_financial\_type DROP INDEX index\_entity\_id\_entity\_table\_account\_relationship" but MySQL can't do it and says 'check that column/key exists'. Also tried 'ALTER TABLE civicrm\_entity\_financial\_account DROP INDEX index\_entity\_id\_entity\_table\_account\_relationship' with the same result

> **Operation failed: Update Indices DB Error: already exists Debug information: CREATE UNIQUE INDEX index\_entity\_id\_entity\_table\_account\_relationship ON civicrm\_entity\_financial\_account (entity\_id, entity\_table, account\_relationship) \[nativecode=1062 \** Duplicate entry '5-civicrm\_financial\_type-3' for key 'index\_entity\_id\_entity\_table\_account\_relationship'\]**

# Answer
> 4 votes
You can apply this PR \- and reload System status page. This will let you know in advance which indices are already present in DB and would result in DB error on hitting Update Indices button. So what need to be done is -

* Apply this PR.
* Reload System status page.
* Some duplicate indices would be shown above `Update Indices` button including a message of what needs to be done.
* Delete indices manually from the DB (which are listed on above step).
* Execute `Update Indices` button.

Update: just saw the error again - So the error say you have two rows which contain the same values for (entity\_id, entity\_table, account\_relationship) as 5, civicrm\_financial\_type and 3 respectively. This should not be there as this group of fields are meant to be unique. To remove this error, you can -

* Open `civicrm_entity_financial_account` table.
* Search for rows that match `entity_id = 5`, `entity_table = civicrm_financial_type` and `account_relationship = 3`. You'll get two rows(This table should allow only one after indexing), delete one of them and re-execute `Update Indices` button. This is not provided by core as of now, so we have to do this manually.

---
Tags: database, 4.7, upgrade
---


# Question
Title: Mosaico - ImagickDraw unable to load any image on templates
After enabling the latest Mosaico on one site, we found the icons are not loaded after adding a new template. After dragging the image from the left to place on the template the image is displayed as below -

On opening the ajax url in a new window, it says -

> The Image \<258\*150\_url\> cannot be displayed because it contains errors\`

# Answer
> 2 votes
After looking for a while, I found this was due to the whitespace before `<?php` i.e

```
<space><?php (starting of the file)

```

in `civicrm_settings.php` file which was messing the png file generation. On removing this space, the image was loaded correctly without errors. So if anyone encounters this error, make sure all your included files are white-space free before `<?php`.

Update: This normally occurs due to an invalid image that is formed by the headers. Flushing the headers with `ob_clean()` just before specifying the same have also worked for some users. There is a great answer https://stackoverflow.com/a/2591854/4243217 which explains about the space issue while creating image using ImagickDraw(used by Mosaico).

---
Tags: mosaico, imagick
---


# Question
Title: Stripe extension fails with a new account (civi 4.7.20)
I have been using Stripe extension (4.7.1) successfully, on several accounts, for several months (using webform integration).

I have just upgraded civi to 4.7.20 (/Drupal 7.56), and everything still works fine.

But now :

I have just openned a new Stripe account, created a pertaining Payment Processor, Contribution Page, and a webform to manage Contributions (as I previously did for previous accounts).

* When I make a contribution using this webform, my payment goes to an other Stripe account.
* When I make a contribution simply using the Contribution Page (https://mysite.com/civicrm/contribute/transact?reset=1&id=xx), I get the following message : "Stripe.js token was not passed! Report this message to the site administrator."

Any help is welcome.

# Answer
> 0 votes
I have just upgraded Stripe Extension to 4.7.dev, which solved the second issue (stripe.js token not passed).

I close this post and open a new one to be more precise concerning the first issue (payment goes to an other account) : see : Webform Contribution Payment is paid to a wrong Account

---
Tags: stripe
---


title: Confused About API Results

text:
# Question
Title: Confused About API Results
Right now I am using the API Explorer (in 4.7.21) just to get the pieces I need for some custom code in Drupal. I am just very confused about what the API Explorer is returning. I am guessing this me not a bug.

If I execute the following with the Case ID of 223 then I should get back the contact assigned to that case.

```
$result = civicrm_api3('CaseContact', 'get', array(
  'sequential' => 1,
  'return' => array("contact_id"),
  'id' => 223,
));

```

When I execute this I get the contact for case 224.

If I use the API to query for the *Subject* of the case for ID 223 I get the expected results and the same for 224.

```
$result = civicrm_api3('Case', 'get', array(
  'sequential' => 1,
  'return' => array("subject"),
  'id' => 223,
));

```

If anyone sees my error here I would appreciate it. If this is a bug I am glad to put it only issues.civicrm.org.

Thanks!

# Answer
> 1 votes
It should be 'case\_id' =\> 223 instead of 'id' =\> 223 for the CaseContact one. It seems to work with either on the public demo, but that might be coincidence - in the civicrm\_case\_contact table the 'id' field is an autoincrement technically unrelated to case\_id, but may or may not match the case\_id depending on creation order, multiple clients, and other happenings.

I would use 'case\_id', like so

`$result = civicrm_api3('CaseContact', 'get', array(
 'sequential' => 1,
 'return' => array("contact_id"),
 'case_id' => 223,
));`

---
Tags: api, civicase
---


# Question
Title: Display CiviCRM Price Set end date in view
I am trying to display the end date of a price set in a view. It seems like that data is stored in Price Field, but I can't figure out how to make that accessible in the view. I installed the CiviCRM Entities module, which has given me access to the Price Set entity, but not the Price Field entity.

I am using Drupal 7 and CiviCRM 4.6.28.

# Answer
If you install the CiviCRM Entity Views Extras module you will be able to add a Views relationship to access the price field fields in your view
> 1 votes

---
Tags: drupal-views, price-sets
---


# Question
Title: Multiple errors after upgrading to 4.7.21 and Joomla 3.7.3
E.g. here: https://www.evergreenmtb.org/support-us/donate

All those files (listed in Chrome's Console w/ errors) do exist, permissions are 644... what am I missing? This started after upgrading to 4.7.21 and Joomla 3.7.3.

Any pointers greatly appreciated : )

# Answer
> 2 votes
This was caused by \[civicrm.root\] using https://www.mydomain.com/components/com\_civicrm/civicrm/

while it should be using http://www.example.com/administrator/components/com\_civicrm/civicrm/

The $civicrm\_root variable is correct in both civicrm.settings.php files so I'm really confused why CiviCRM cannot pull the civicrm.root variable correctly.

---
Tags: joomla, 4.7
---


# Question
Title: Wrong headings diplaying on contact search results
Using CiviCRM version 4.7.20 on WordPress 4.8 the headings are wrong on the results of Find Contacts and also Advanced Find. They are all shifted three places to the left, cyclically. The links on the headings match their names.

I've added a few custom fields and profiles, but not changed any code.

Very odd and looks like I'll have to reinstall it all again.

# Answer
> 1 votes
This was i believe fixed in 4.7.21 See https://issues.civicrm.org/jira/browse/CRM-20644

---
Tags: wordpress, search
---


# Question
Title: Multi-select not working with crmUiSelect AngularJS select2 directive
I created a select2 element with CiviCRM's `crmUiSelect` AngularJS directive by using the following code in my controller:

```
$scope.options = [
  {"value": "foo", "label": "Foo"},
  {"value": "bar", "label": "Bar"},
  {"value": "baz", "label": "Baz"},
  {"value": "bat", "label": "Bat"}
];

```

and the following code in my template:

```
<select
  crm-ui-select="{allowClear: true}"
  ng-model="myVar"
  ng-options="option as option.label for option in options track by option.value"
  multiple="multiple"
  class="big"
>
</select>

{{myVar}}

```

It sort of worked, but here's what I ended up with:

As you can see in the above screenshot, this element has the following problems:

* `myVar` is an array with only *one* element, even when multiple options are selected.
* The list of options contains options which have already been selected (and the element actually allows these options to be selected more than once).

How can I fix this element so that it works as expected? I want `myVar` to become `["foo", "bar"]` in the screenshot above, and I want the user to only see options which have not already been selected.

# Answer
For some reason, you can't use the `ngOptions` directive with select2 multi-select elements. You need to manually specify the `<option>` elements with `ngRepeat` like this instead:

```
<select
  crm-ui-select="{allowClear: true}"
  ng-model="myVar"
  multiple="multiple"
  class="big"
>
  <option ng-repeat="option in options" value="{{option.value}}">
    {{option.label}}
  </option>
</select>

{{myVar}}

```

That produces the desired behavior:
> 1 votes

---
Tags: developer, angular, select2
---


# Question
Title: CiviCRM Can't Connect to Databases on Server, but WordPress Can
I've been trying to install CiviCRM on fresh WordPress 4.7.3 installations on my managed server, but I keep having database connection problems.

When I try to install CiviCRM 4.7.17, the CiviCRM installer can't locate the database or validate any of the database details.

The MySQL server "Does the server exist?" line returns this message: \*Can't find the a MySQL server on 'localhost:/tmp/mysql.sock'.: Unknown MySQL server host 'localhost:/tmp/mysql.sock' (2)\**

I am using exactly the same database information --MySQL server at localhost:/tmp/mysql.sock/-- that I used to successfully install WordPress.

I've also tried installing CiviCRM 4.6.0 and 4.6.26 on separate fresh installations of WordPress 4.7.3. In both of these attempts, the CiviCRM installer locates the database just fine (using localhost:/tmp/mysql.sock as the MySQL server), and says that the installation has completed successfully after I click "Install."

However, when I click on the CiviCRM tab in both instances, this error appears, and CiviCRM fails to open:

Array ( \[callback\] =\> Array ( \[0\] =\> CRM\_Core\_Error \[1\] =\> simpleHandler )

```
[code] => -24
[message] => DB Error: connect failed
[mode] => 16
[debug_info] =>  [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]
[type] => DB_Error
[user_info] =>  [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]
[to_string] => [db_error: message="DB Error: connect failed" code=-24 mode=callback callback=CRM_Core_Error::simpleHandler prefix="" info=" [nativecode=Can't connect to local MySQL server through socket '/set-in-php.ini' (2)]"]

```

)

I've contacted my managed server's administrators about this, but they think this is CiviCRM-specific problem and haven't been able to help.

We're using PHP 5.6.30. Our other server information is as follows:

Server: Localhost via UNIX socket Server type: MySQL Server version: 5.5.27 - MySQL Community Server (GPL) Protocol version: 10 User: root@localhost

Apache/2.2.32 (Unix) mod\_ssl/2.2.32 OpenSSL/1.0.1e-fips PHP/5.6.30 mod\_pubcookie/3.3.4a mod\_uwa/3.2.1 Database client version: libmysql - 5.5.18 PHP extension: mysqli

This PHP warning pops up in our error logs every time I try to access a CiviCRM installation unsuccessfully:

PHP Warning: mysqli\_real\_escape\_string() expects parameter 1 to be mysqli, boolean given in /data/www/**\_our\____website\_**/wp-content/plugins/civicrm/civicrm/install/index.php on line 1256

Line 1256 in index.php is: global $installDirPath;

I'm not sure what's causing this problem, and I appreciate any insights you might have.

---

Per Jon G's note below: the civicrm.settings.php files that are generated in the installation appear to be standard.

The default settings files that are generated return the following database lines:

if (!defined('CIVICRM\_UF\_DSN')) { define( 'CIVICRM\_UF\_DSN' , 'mysql://username:password@localhost:/tmp/mysql.sock/civicrm-again?new\_link=true'); }

...which look standard. In the past, I've had to manually edit these lines to accommodate the non-standard localhost location (localhost:/tmp/mysql.sock) by inserting tcp( ), like this:

if (!defined('CIVICRM\_UF\_DSN')) { define( 'CIVICRM\_UF\_DSN' , 'mysql://username:password@**tcp(\**localhost:/tmp/mysql.sock**)\**/civicrm-again?new\_link=true'); }

After that --in the past-- CiviCRM worked fine.

Now, neither the default version nor the adjusted tcp() one allows CiviCRM to initialize in my successful 4.6 installations. (I've also tried inputting just "localhost" in place of "localhost:/tmp/mysql.sock" here, but that returns the same error.)

Finally, the MySQL server is running on the standard port, 3306.

---

Also, I should mention two other things: I installed CiviCRM in 4.6.0 on our server successfully in the past, and this version was working fine till I tried to upgrade to 4.7.17. Since running the upgrade script, clicking on the CiviCRM tab returns an HTTP error 500.

Also, for this and the other 4.6 installations, I adjusted a line in the installation code in modules/civicrm/install/civicrm.php, adding an additional tcp(...) around the server location, per this thread: https://forum.civicrm.org/index.php?topic=12500.0;prev\_next=prev#new

The revised line looks like this: $dsn = "mysql://{$config\['mysql'\]\['username'\]}:{$config\['mysql'\]\['password'\]}@tcp({$config\['mysql'\]\['server'\]})/{$config\['mysql'\]\['database'\]}?new\_link=true";

---

**UPDATE:** I'm still not able to install CiviCRM 4.7.18, but I was able to upgrade my previous database to 4.7.22 by adjusting the civicrm.settings.php file. I got it to work by adding @tcp( ) to civicrm.settings.php (as mentioned above), changing "localhost" to 127.0.0.1, and specifying the port as :3306. The lines I changed were:

define( 'CIVICRM\_UF\_DSN'; 'mysql://user:password@tcp(127.0.0.1:3306)/database?new\_link=true'); define('CIVICRM\_DSN', 'mysql://user:password@tcp(127.0.0.1:3306)/database?new\_link=true'); define('CIVICRM\_DB\_CACHE\_HOST', '127.0.0.1'); define('CIVICRM\_DB\_CACHE\_PORT', 3306 );

After running the upgrade script again, the upgrade worked!

# Answer
Spent a few hours trying to solve this problem and found the solution to my problem was to add 3306 to the server address. It does say if your server is not using the standard port them to indicated the port. I'm guessing it was trying to use sockets to connect but by using the port address it knows which one to use.

I also found that installing from a zip file worked better than trying a manual install. The only problem was my Php had a file size limit which needed to be increased but apache kept reporting the upload was to big. In the end used a plug in to upload larger files for wordpress upload larger plugins. Now just have a problem with the crm not seeing curl.
> 2 votes

# Answer
It sounds like you've got something unusual in your `civicrm.settings.php` file. Here's what the relevant lines look like for me:

```
define( 'CIVICRM_UF_DSN'           , 'mysql://nwu:<password>@localhost/nwu_wp?new_link=true' );
define( 'CIVICRM_DSN'          , 'mysql://nwu:<password>@localhost/nwu_wpcivicrm?new_link=true' );

```

Please check the corresponding lines in your installation. If you're not sure how to fix it, please update your question to include those lines - make sure to redact your password!
> 1 votes

---
Tags: wordpress, database, mysql
---


# Question
Title: how to transfer data from one server to new one for Civi CRM on wordpress
we have data in wordpress based Civi CRM on one server and want to migrate to another server with wordpress. please guide us.

# Answer
There is a section in the CiviCRM documentation on moving to a new server. Its not so thorough on WordPress as the other platforms but you should be able to work it all out from the information at https://wiki.civicrm.org/confluence/display/CRMDOC/Moving+an+Existing+Installation+to+a+New+Server+or+Location
> 1 votes

---
Tags: wordpress, database, migration
---


title: How to find and/or fix missing indices?

text:
# Question
Title: How to find and/or fix missing indices?
After upgrading to 4.7.19, I'm now getting a warning: You have missing indices on some tables. This may cause poor performance.

How can I find which indices are missing and then, how can I create them?

# Answer
**Disclaimer, as with other answers, this is aimed at a fairly technical person who kinda understands what they're doing and has made lots of backups :-)**

As Sophie points out you can find the exact problem looking at the latest log in the `ConfigAndLog` directory.

For several of us the problem has been that there's a key **defined incorrectly** and the script's current response is to try a `CREATE INDEX...` statement, but it already exists, so it fails. Furthermore dropping this index with a simple `DROP KEY <keyname> ON <table> ....` cannot be done where a foreign key (FK) depends on having an index on those columns, as pointed out by Aidan

Temporarily disabling FKs can be problematic. The way I got it up and running was as follows:

1. Run the fixer, either from the status page or (for drupal users) with

```
drush cvapi System.updateindexes

```

If it didn't work, read on.
2. Inspect the latest file in `ConfigAndLog` to find the table where it died. In my case this looked like

```
CREATE UNIQUE INDEX UI_case_contact_id ON civicrm_case_contact
(case_id, contact_id) [nativecode=1061 ** Duplicate key name
'UI_case_contact_id'

```

So it's the `UI_case_contact_id` key that's the problem here.
3. Attempt to delete that key, if this works you can go back to step 1.

```
drush civicrm-sql-cli
MariaDB [your_db]> DROP INDEX UI_case_contact_id ON civicrm_case_contact;

```
4. If deleting the key fails due to a FK constraint, e.g. like this:

```
ERROR 1553 (HY000): Cannot drop index 'UI_case_contact_id': needed
in a foreign key constraint.

```

Then create the same key with a different name - copy the definition from the error message in (2), e.g.

```
CREATE UNIQUE INDEX my_temp_key ON civicrm_case_contact
(case_id, contact_id);

```

You should now be able to go back to step 3 and successfully delete the original key since now the FK can depend on your new key called `my_temp_key`.
5. Re-run the updater, hopefully it's ok (on that table/key at least) now. If so you can then delete your `my_temp_key` with

```
DROP INDEX my_temp_key ON civicrm_case_contact;

```

Nb. Several of us have had this part fail. This means the update script has not created the index for some reason. If this happens I'd advise it would probably be best practise to reissue the original `CREATE INDEX` command from the log (step 2 above), then you should be able to drop your temporary key ok. This way you leave the schema exactly as CiviCRM expects it to be, which is definitely going to be helpful in the long term.

I put this solution together standing on the observations shared by others credited above, just thought it might be useful for me to spell out a step by step process. :-)
> 15 votes

# Answer
The pop-up message should have a link "View details and manage alerts" that takes you to the System Status page. That includes an `Update Indices` button (yes there is a typo in 4.7.19 but it doesn't affect the function).

`Update Indices` *should* create the missing indices which may take a while depending on which indices are missing and how much data you have in the affected tables, and then return you to the System Status page without that warning.

However, there is a bug (https://issues.civicrm.org/jira/browse/CRM-20533) that causes the index creation to fail when an index of the same name already exists.

If that affects your system, the warning will persist until a future release when this is fixed. If that bothers you, you can use the 'Hide' option.

Note that this is warning of a problem that has likely been in your system for a while: the problem is not new, but the check and the attempt to fix it is new in 4.7.19.

Kainuk's answer shows how to list the missing indices on a Drupal system, or for any CMS you can use:

`cv ev 'print_r(CRM_Core_BAO_SchemaHandler::getMissingIndices())'`

and run the update with

`cv api System.updateindexes`
> 10 votes

# Answer
After upgrading to 4.7.19 I found that indices cannot be created automatically; you can look at your CiviCRM error log to see which database statement is causing a fatal error - you might see problems such as a duplicate index.

In my case I had to run these database statements before/after repairing indices, but it could be different on your site:

```
ALTER TABLE civicrm_prevnext_cache DROP INDEX index_all;
ALTER TABLE civicrm_option_value DROP FOREIGN KEY `FK_civicrm_option_value_option_group_id`;
ALTER TABLE civicrm_option_value DROP INDEX index_option_group_id_name;
ALTER TABLE civicrm_entity_tag DROP INDEX UI_entity_id_entity_table_tag_id;

```

Then, click the index repair button, and finally, restore the constraint:

```
ALTER TABLE civicrm_option_value ADD CONSTRAINT `FK_civicrm_option_value_option_group_id` FOREIGN KEY (`option_group_id`) REFERENCES `civicrm_option_group` (`id`) ON DELETE CASCADE;

```
> 6 votes

# Answer
Had the same problem when I went from 4.7.14 to 4.7.20, same resolution as @mfb but with a different index. Default location for the error logs is

> /sites/default/files/civicrm/ConfigAndLog

There I found an error adding the index UI\_case\_contact\_id . Coincidentally, this was the first index listed when running the drush ev command per @Kainuk above. Still had to fix via db. For me it was:

```
ALTER TABLE civicrm_case_contact DROP FOREIGN KEY `FK_civicrm_case_contact_contact_id`;
ALTER TABLE civicrm_case_contact DROP FOREIGN KEY `FK_civicrm_case_contact_case_id`;
ALTER TABLE civicrm_case_contact DROP INDEX UI_case_contact_id;

```

Clicked on the button on the civicrm/a/#/status page, then ran these queries to restore the constraints

```
ALTER TABLE civicrm_case_contact ADD CONSTRAINT `FK_civicrm_case_contact_contact_id` FOREIGN KEY (`contact_id`) REFERENCES `civicrm_contact` (`id`) ON DELETE CASCADE;
ALTER TABLE civicrm_case_contact ADD CONSTRAINT `FK_civicrm_case_contact_case_id` FOREIGN KEY (`case_id`) REFERENCES `civicrm_case` (`id`) ON DELETE CASCADE;

```

BTW, even though drush wasn't needed to solve this problem, these sites were helpful getting it installed: https://www.drupal.org/node/2809987#comment-11684107 http://endlessgeek.com/2014/03/install-drush-cpanel-shared-hosting/
> 5 votes

# Answer
Are you using Drupal and do you have access to `drush`? Then you can use the shell. To show the missing indexes do:

```
 drush ev 'civicrm_initialize();print_r(CRM_Core_BAO_SchemaHandler::getMissingIndices())'

```

To create them use

```
 drush cvapi System.updateindexes

```
> 4 votes

# Answer
From the system check screen you should be able to click on a button to add them. Most likely this is because you are missing newly added indices

e.g from http://yoursite/civicrm/a/#/status

You should have an option to add the indices. Note that on a large site they may require an outage to add them as they may take a while
> 1 votes

# Answer
I upgraded from 4.7.8 to 4.7.20. After seeing 'missing indices' status msg I saw that table civicrm\_case\_contact did indeed have foreign keys for both contact\_id and case\_id- that's about all it has, being a link table. The problem is in the function that builds the existing\_sigs, required\_sigs arrays for SchemaHandler:findMissingIndices comparing civicrm\_case\_contact::1::case\_id::contact\_id with civicrm\_case\_contact::0::contact\_id Other tables listed as 'missing indices' included civicrm\_uf\_group:name but column `name` is not constrained to being unique; and civicrm\_activity:status\_id which is allowed to be null. This is a very useful function in theory, but maybe needs some work? Thank you all
> 0 votes

---
Tags: upgrade, database
---


title: Error when installing CiviVolunteer

text:
# Question
Title: Error when installing CiviVolunteer
Not sure how to resolve this. Getting the error when installing org.civicrm.volunteer

> Sorry but we are not able to provide this at the moment. DB Error: unknown error

Here is the backTrace log:

backTrace

```
0 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Error.php(187): CRM_Core_Error::backtrace()

1 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(921): CRM_Core_Error::handle(Object(DB_Error))

2 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB.php(984): PEAR_Error->__construct("DB Error: unknown error", -1, 16, (Array:2), "INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...")

3 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(575): DB_Error->__construct(-1, 16, (Array:2), "INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...")

4 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/PEAR.php(223): PEAR->_raiseError(Object(DB_mysqli), NULL, -1, 16, (Array:2), "INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...", "DB_Error", TRUE)

5 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1905): PEAR->__call("raiseError", (Array:7))

6 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(933): DB_common->raiseError(-1, NULL, NULL, "INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...", "1292 ** Incorrect datetime value: '0' for column 'created_date' at row 1")

7 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/mysqli.php(403): DB_mysqli->mysqliRaiseError()

8 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/common.php(1216): DB_mysqli->simpleQuery("INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...")

9 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(2446): DB_common->query("INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...")

10 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/DB/DataObject.php(1068): DB_DataObject->_query("INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...")

11 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/DAO.php(495): DB_DataObject->insert()

12 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Migrate/Import.php(132): CRM_Core_DAO->save()

13 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Migrate/Import.php(213): CRM_Utils_Migrate_Import->copyData(Object(CRM_Core_DAO_CustomGroup), Object(SimpleXMLElement), TRUE, "name")

14 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Utils/Migrate/Import.php(80): CRM_Utils_Migrate_Import->customGroups(Object(SimpleXMLElement), (Array:2))

15 /home/replaced/domains/test.replaced.org/public_html/wp-content/uploads/civicrm/ext/org.civicrm.volunteer/CRM/Volunteer/Upgrader.php(787): CRM_Utils_Migrate_Import->runXmlElement(Object(SimpleXMLElement))

16 /home/replaced/domains/test.replaced.org/public_html/wp-content/uploads/civicrm/ext/org.civicrm.volunteer/CRM/Volunteer/Upgrader.php(48): CRM_Volunteer_Upgrader->executeCustomDataTemplateFile("volunteer-customdata.xml.tpl")

17 /home/replaced/domains/test.replaced.org/public_html/wp-content/uploads/civicrm/ext/org.civicrm.volunteer/CRM/Volunteer/Upgrader/Base.php(306): CRM_Volunteer_Upgrader->install()

18 /home/replaced/domains/test.replaced.org/public_html/wp-content/uploads/civicrm/ext/org.civicrm.volunteer/volunteer.civix.php(54): CRM_Volunteer_Upgrader_Base->onInstall()

19 /home/replaced/domains/test.replaced.org/public_html/wp-content/uploads/civicrm/ext/org.civicrm.volunteer/volunteer.php(262): _volunteer_civix_civicrm_install()

20 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager/Module.php(76): volunteer_civicrm_install()

21 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager/Module.php(48): CRM_Extension_Manager_Module->callHook(Object(CRM_Extension_Info), "install")

22 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Extension/Manager.php(229): CRM_Extension_Manager_Module->onPreInstall(Object(CRM_Extension_Info))

23 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Form/Extensions.php(181): CRM_Extension_Manager->install((Array:1))

24 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Form.php(447): CRM_Admin_Form_Extensions->postProcess()

25 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/StateMachine.php(160): CRM_Core_Form->mainProcess()

26 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/QuickForm/Action/Next.php(61): CRM_Core_StateMachine->perform(Object(CRM_Admin_Form_Extensions), "next", "Next")

27 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Controller.php(203): CRM_Core_QuickForm_Action_Next->perform(Object(CRM_Admin_Form_Extensions), "next")

28 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/packages/HTML/QuickForm/Page.php(103): HTML_QuickForm_Controller->handle(Object(CRM_Admin_Form_Extensions), "next")

29 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Controller.php(351): HTML_QuickForm_Page->handle("next")

30 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(384): CRM_Core_Controller->run()

31 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Page/Basic.php(168): CRM_Core_Page_Basic->edit(1, NULL)

32 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Admin/Page/Extensions.php(121): CRM_Core_Page_Basic->run()

33 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(310): CRM_Admin_Page_Extensions->run((Array:3), NULL)

34 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:13))

35 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3))

36 /home/replaced/domains/test.replaced.org/public_html/wp-content/plugins/civicrm/civicrm.php(1227): CRM_Core_Invoke::invoke((Array:3))

37 /home/replaced/domains/test.replaced.org/public_html/wp-includes/class-wp-hook.php(298): CiviCRM_For_WordPress->invoke("")

38 /home/replaced/domains/test.replaced.org/public_html/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters("", (Array:1))

39 /home/replaced/domains/test.replaced.org/public_html/wp-includes/plugin.php(453): WP_Hook->do_action((Array:1))

40 /home/replaced/domains/test.replaced.org/public_html/wp-admin/admin.php(222): do_action("toplevel_page_CiviCRM")

41 {main}

```

# Answer
If you check the trace it's importing from

`CRM_Volunteer_Upgrader->executeCustomDataTemplateFile("volunteer-customdata.xml.tpl")`

That causes the error:

`"INSERT INTO civicrm_custom_group (name , title , extends , extends_entity_col...", "1292 ** Incorrect datetime value: '0' for column 'created_date' at row 1"`

There's an open issue for this on CiviVolunteer that shows a workaround.

There's also this issue, and I've had experience where I've just had to remove the `created_date` from the XML, so hopefully this will be resolved in the future.
> 1 votes

---
Tags: wordpress, installation, civivolunteer
---


# Question
Title: Upgrade to Drupal 4.7.12 failed (while upgrading from 4.7.11 to 4.7.21)
Trying to upgrade from 4.7.11 to 4.7.12 but failed.

Here is debug info:

```
[Error: Add Data Type column to civicrm_option_group]
Error Field Error Value
Type    DB_Error
Code    -19
Message DB Error: no such field
Mode    16

UserInfo:
    UPDATE `civicrm_option_group_en_US` SET `data_type` = 'Integer' WHERE name IN ('activity_type', 'gender', 'payment_instrument', 'participant_role', 'event_type') [nativecode=1054 ** Unknown column 'data_type' in 'field list']

DebugInfo
    UPDATE `civicrm_option_group_en_US` SET `data_type` = 'Integer' WHERE name IN ('activity_type', 'gender', 'payment_instrument', 'participant_role', 'event_type') [nativecode=1054 ** Unknown column 'data_type' in 'field list']

```

However, field `data_type` DOES exist.

# Answer
> 1 votes
The solution is to manually create `data_type` field in `log_civicrm_option_group` table.

```
ALTER TABLE `log_civicrm_option_group` ADD `data_type` VARCHAR(128)
CHARACTER SET utf8 COLLATE utf8_unicode_ci
NULL DEFAULT NULL
COMMENT 'Data Type of Option Group.';

```

---
Tags: drupal, upgrade
---


# Question
Title: Upgrading to 4.7.21 on Wordpress get uncaught exception on status page
After uploading the 4.7.21 plugin the CiviCRM admin pages loaded ok with the status at bottom indicating new version and of course with a red 'System Status' warning. On clicking this to get to the status page to update db etc, got this error: Uncaught exception: You have requested a non-existent service "asset\_builder".

Tried installing clean copy again. Same result. Resolved issue by manually entering the upgrade page url. This brought up expected option to upgrade db. All well after this. https://xxx/wp-admin/admin.php?page=CiviCRM&q=civicrm/upgrade&reset=1

Question: is this just our installation or have others had same behaviour, and did this fix resolve?

# Answer

> 1 votes

---
Tags: wordpress, upgrade
---


# Question
Title: Setting up Cron Jobs to run Initially(Cron Not Running)
I've recently setup civicrm as a plugin on my wordpress site, and I can't seem to shake the 'Cron Not Running' Warning.

Does the `job.execute` cron job need to be running in order to run all other scheduled jobs?

I'm on a digital ocean ubuntu server, and each time i run

```
sudo -u www-data -- /usr/local/bin/wp --user=cronuser --
url=https://mysite.org --path=/var/www/html civicrm api job.execute
auth=0

```

it will run the scheduled tasks, and the system warning will go away(for an hour or so) but this is kind of a 1-off behavior, and it doesn't continue to run any tasks that have already been set up. Eventually, the warning comes back.

Do I need to do something like `crontab -e` and then:

```
* * * * * sudo -u www-data -- /usr/local/bin/wp --user=cronuser --
url=https://mysite.org --path=/var/www/html civicrm api job.execute
auth=0

```

I'm new to linux administration and I don't want to mess anything up by "guessing" what will work.

# Answer
> 0 votes
I'm assuming you've seen this Wiki page: https://wiki.civicrm.org/confluence/display/CRMDOC/Managing+Scheduled+Jobs

If I'm reading your question correctly, I think you need to set up the cron job so it runs every so often, e.g. every 15 minutes:

```
*/15 * * * * <your cron job command here>

```

---
Tags: cron-job, cron
---


# Question
Title: Missing indices status after upgrading to CiviCRM 4.7.21 on WordPress 4.8
I successfully upgraded to CiviCRM 4.7.21 (from 4.7.17), and everything seems to be working properly. However, I got a critical status error, "Performance warning: Missing indices". After reading How to find and/or fix missing indices? I tried bringing up the status screen to correct the error, but the status screen comes up empty. However, I continue to see "System Status Critical" highlighted in pink near the top of the screen. (See screenshot below.)

I downloaded the latest log from /wp-content/uploads/civicrm/ConfigAndLog, but I don't see anything relating to indices in it. (Log included below.)

Any ideas where to go from here?

```
Jul 09 15:58:28  [info] Running task: Cleanup old files

Jul 09 15:58:29  [info] Running task: Begin Upgrade to 4.7.18

Jul 09 15:58:30  [info] Running task: Upgrade DB to 4.7.18

Jul 09 15:58:31  [info] Running task: Update Kenyan Provinces

Jul 09 15:58:31  [info] Running task: Upgrade DB to 4.7.18: SQL

Jul 09 15:58:32  [info] Running task: Finish Upgrade DB to 4.7.18

Jul 09 15:58:33  [info] Running task: Begin Upgrade to 4.7.19

Jul 09 15:58:34  [info] Running task: Upgrade DB to 4.7.19

Jul 09 15:58:34  [info] Running task: Drop Column current_period_opening_balance From civicrm_financial_account table.

Jul 09 15:58:35  [info] Running task: Drop Column opening_balance From civicrm_financial_account table.

Jul 09 15:58:36  [info] Running task: CRM-19961 - Add domain_id column to civicrm_sms_provider

Jul 09 15:58:37  [info] Running task: CRM-19961 - Populate domain id table and perhaps add foreign key

Jul 09 15:58:37  [info] Running task: Upgrade DB to 4.7.19: SQL

Jul 09 15:58:38  [info] Running task: CRM-16633 - Add "Change Case Subject" activity

Jul 09 15:58:39  [info] Running task: Add is_public column to civicrm_custom_group

Jul 09 15:58:40  [info] Running task: Finish Upgrade DB to 4.7.19

Jul 09 15:58:41  [info] Running task: Begin Upgrade to 4.7.20

Jul 09 15:58:41  [info] Running task: Upgrade DB to 4.7.20

Jul 09 15:58:42  [info] Running task: Fix Schema on civicrm_action_schedule

Jul 09 15:58:43  [info] Running task: Upgrade DB to 4.7.20: SQL

Jul 09 15:58:44  [info] Running task: Add activity_status column to civicrm_mail_settings

Jul 09 15:58:44  [info] Running task: Finish Upgrade DB to 4.7.20

Jul 09 15:58:45  [info] Running task: Begin Upgrade to 4.7.21

Jul 09 15:58:46  [info] Running task: Upgrade DB to 4.7.21

Jul 09 15:58:47  [info] Running task: Finish Upgrade DB to 4.7.21

```

# Answer
This problem has been raised before and you can view the thread at How to find and/or fix missing indices?

There is also an entry in JIRA at the following link https://issues.civicrm.org/jira/projects/CRM/issues/CRM-20533?filter=allissues

Hope this helps.
> 1 votes

# Answer
You can execute run indices under system status, and tail the CiviCRM log for any exceptions during the process (such as rebuilding the foreign keys).

I had a few fatal errors, so the process would never complete due to existing foreign key constraints in the DB. Idid a MySQL dump of the DB and commented out the offending foreign keys which were then recreated by the CiviCRM update indices process.

Unfortunately can't grab the URL directly because it has been run. I could check your Javascript console in the browser to see why the status page isn't loading. I believe it does an AJAX request to populate the status page.
> 0 votes

---
Tags: wordpress, upgrade, indices, status
---


# Question
Title: Cannot send email from CiviCRM after upgrade to 4.7.21 (Joomla 3.7.3)
After upgrading CiviCRM to 4.7.21 (on Joomla 3.7.3), no emails get sent from CiviCRM (transactional or from CiviMailing). In *System Settings \>\> Outbound Email (SMTP/Sendmail)* when I click on "Save and Send Test Email" the page keeps reloading for about a minute, and then results in 500 error ("This page isn't working").

This worked perfectly before the upgrade.

Also, I no longer see file packages/Net/SMTP.php (I re-ran the CiviCRM install just in case) which used to send email via SMTP ... is this now handled by another file in another directory? Thank you so much for any pointers.

# Answer
> 1 votes
As Mark said this is a known regression and we are looking at an expedited release. However as i can feel even a release this coming US Wednesday may be a bit late.

What i would advise you to do is to if you cannot wait make a patch to the file vendor/pear/net\_smtp/Net/SMTP.php along the lines of https://github.com/civicrm/civicrm-core/pull/10622/files. The relevant block of code will be around ~line 600 of that particular file.

Otherwise wait until 4.7.22 comes out which will be very soon. In regards to why this may not affect all users, it only affects users if they need to authenticate to the SMTP server over TLS

---
Tags: joomla, email, 4.7, mailserver, 4.7.21
---


title: Using CiviCRM API in Drupal View

text:
# Question
Title: Using CiviCRM API in Drupal View
I am trying to use the Civi API within a Drupal view, in the global PHP field.

It is all working, except for when I try to use an "Available Variable" from the view, it throws and error. When I hard code the variable's value, it works, though.

The variable I am using does contain the correct data; if I return just that variable, it returns the ID it should.

**The code:**

```
civicrm_initialize();
$start_date = civicrm_api3('price_field', 'getvalue', array(
  'return' => 'active_on',
  'price_set_id' => $row->price_set_id,
));

return gettype($start_date);'

```

**Error** field active\_on unset or not existing

I am using Drupal 7 and CiviCRM 4.6.28.

# Answer
> 1 votes
As far as your API call there goes...I don't see an 'id' =\> $row-\>price\_field\_id in there. You'll need to query by id to get the value for each individual price field. I'm not exactly sure what the variable name on the object will be in your case...but the main thing is to query for the individual price fields data by id

---
Tags: api, drupal-views, php
---


title: Disable select2 in drupal

text:
# Question
Title: Disable select2 in drupal
I have some forms in drupal 7 using native civicrm, and some using webform integration. The webforms use normal select dropdowns for state and country, but when i create a contribution page in civi, it uses styled select2 dropdowns. I would like to disable this and just have plan selects. Is it possible?

# Answer
> 3 votes
The easiest way to do this would probably be to add a teeny script to the page footer of your webform that does:

```
CRM.$.fn.crmSelect2 = function(){};

```

# Answer
> 0 votes
Yes it is possible but you would need to edit the template that is being used. Without knowing where the select box is on your contribution page, I can't say which template you need to edit. I suggest using firebug or chrome dev tools to pick out some of the surrounding html and doing a text search to see which template is being used. Then you can follow the docs for making a custom template.

It is not difficult to do this, but it is not ideal because if the template gets updated, yours will be left behind.

It would be better to add some custom css so that the select2's are made to look like the other select boxes. However I have never found a quick or easy way of adding custom CSS to Civi. If you are already using a custom Drupal theme you could add the CSS to your theme. Otherwise the template method is probably the best way to go.

# Answer
> 0 votes
An alternative way of getting webform selects to match each other would be to make them *all* select2. It's a nice widget - you might like it :)

This module can do that for you: https://github.com/colemanw/webform\_select2

And to avoid needing a 2nd copy of the select2 library (along with a whole bunch of other redundant scripts) check out https://www.drupal.org/project/civi\_jquery

# Answer
> 0 votes
In order to work "around" Select2 sometimes behaving inconsistently in automated testing, I've been using this after the page loads to turn those fields back into regular browser selects.

```
CRM.$('.crm-select2').select2('destroy');

```

Coleman suggested that it should be possible to use `$('#my_field').val('foo').change()` to set values, and this works sometimes, but not reliably enough to test with. The above JS can be executed in a test to make forms behave more predictably.

I wouldn't recommend this approach to address select2 for your site end-users, because they will see a "flash of select2 content" effect :) But since lots of people have answered with ways to deal with this, I figured I'd document this approach.

# Answer
> 0 votes
is there a way to disable select2 in CiviCRM pages? e.g. contribution pages.

We added this to the footer of the page to no avail: - `CRM.$('.crm-select2').select2('destroy');`

It is the core code that dictates the styling of some fields?

---
Tags: drupal
---


# Question
Title: How to make the City field a dropdown selection depending on the county selected?
Basically what it says in the title. Currently, the City field in the Address is a free text field. Is it possible to make it dropdown or even auto-complete from a set of predefined cities?

# Answer
I am not sure what you mean by 'is it possible'? My answer would be: yes it is possible but not without coding. You would have to make a small extension that would enable this.
> 1 votes

---
Tags: civicrm-home
---


# Question
Title: Error: Refund amount must equal refund due amount
Has anyone else had this issue where its not possible to get the refund page to save even though the amount is correct?

**Drupal Error Log**

Notice: Undefined index: event in CRM\_Core\_Payment\_ProcessorForm::preProcess() (line 78 of /\****/public\_html/sites/all/modules/civicrm/CRM/Core/Payment/ProcessorForm.php).

# Answer
> 1 votes
Can you try to replicate on dmaster.demo.civicrm.org and if you can replicate it there please create an issue at https://issues.civicrm.org/ and assign it to me (Joe Murray)? Thanks!

---
Tags: drupal, 4.7
---


# Question
Title: How can I chase up mailing list subscribers who don't confirm their opt-in?
When someone adds themselves to a group that is configured as a mailing list they get sent an email with a confirmation link. The email includes the token: {subscribe.url}

We now have something like 2500 people in our database that have joined a mailing list but not confirmed, so they are in a 'pending by email' status. We want to run a campaign to encourage them to confirm their subscription, but the {subscribe.url} token doesn't appear to work in a standard CiviMail mailing.

We can't be the first to have come across this issue. How can we effectively encourage all of these people to confirm their subscription?

# Answer
> 1 votes
Taking answer from comment from @eli lisseck... Try using {action.subscribeUrl.gid} where gid is your group e.g. {action.subscribeUrl.5}. More generally, however, beware of assuming that these people have indeed chosen to signup rather than had their emails added by a bot/spammer. Trying to work around the double opt-in will make your site non-compliant with anti-spam legislation in the US and elsewhere, and will make your site more likely to get blacklisted as a spammer.

---
Tags: civimail, tokens, subscribe
---


# Question
Title: SOLVED: Can't run Upgrade script 4.7.21 (Drupal6) due to unknown column = civicrm_custom_group.is_public
After installing the 4.7.21 upgrade my D6 site shows as upgraded and Civi appears to run correctly. However when I run the upgrade script I get error: `Sorry but we are not able to provide this at the moment. DB Error: no such field`""

If I delve into the error I find: `[nativecode=1054 ** Unknown column 'civicrm_custom_group.is_public' in 'field list']"]`

Can anyone guide me how to fix this?

# Answer
> 3 votes
We have had to create this field in the db in several sites we have upgraded. Not sure why the upgrade script is failing to do this correctly

Fuzion have provided a patch for this to avoid the problem for future folks doing upgrades

# Answer
> 3 votes
SOLVED: For good measure here is a repeat of the above comment.

I was able to successfully install the upgrade to 4.7.21 on Drupal 6 after applying the patch mentioned above, and after disabling Views, CTools and Webform (and all related/dependant modules).

The upgrade then ran smoothly without any problems.

---
Tags: upgrade, drupal-6, 4.7.21
---


title: Add back WYSIWYG buttons

text:
# Question
Title: Add back WYSIWYG buttons
I'm upgrading a site from 4.6.x to 4.7.x. I am having trouble understanding how to configure the WYSIWYG to provide the same CKEditor editor buttons as in the 4.6.x version.

I know that I can go to Administer -\> Customize Data and Screens -\> Display Preferences -\> Configure CKEditor. However, I don't see how to add back missing editor buttons.

For instance, I would like to add back the "Align Left", "Center", "Align Right", and "Justify" buttons. I see that there is an empty toolbar group where these should go. In the "Plugins" dropdown, I see "Justify" but I don't see any of the other missing buttons. And I don't see how to get Justify out of the dropdown and into the toolbar.

Any guidance would be greatly appreciated. Thanks!

# Answer
You need to i think it is enable the justify Plugin that will then give you the align left button. I would also recommend adding in the Font Plugin as well.

Regards

Seamus
> 0 votes

---
Tags: 4.7, wysiwyg
---


title: List of fields and explanations?

text:
# Question
Title: List of fields and explanations?
I am working on importing information from our current donor database to Civi. Is there a table that lists the field names within each table and an explanation of what that is? Specifically I am looking at ContributionRecur entity and I would like an explanation of the fields beyond the field name that's in one place. Ideally each entity would have something like that.

I have looked in the User Guide but I can't find that sort of thing. Can anyone point me as to where it would be ?

# Answer
> 2 votes
One way is to use the API Explorer.

Here's a demo of how it shows you field comments:

# Answer
> 2 votes
One way is to look in the MySQL database directly, if you have access to it. Each table is defined with **comments** for most of the columns, and I have found them to be quite useful.

A great way to inspect the databse directly is to use MySQL Workbench. You can right click on the table and choose **Table inspector**. Here's a screenshot of it which demonstrates its ability to display field comments...

Other database inspection tools like phpMyAdmin should have similar functionality.

# Answer
> 1 votes
One way is to look at the XML schema definitions in the source code. Here is an example of this for ContributionRecur.

To make sense of this code though, you need to read that XML. Look for the `<field>` tags. For example you can see that the field named `frequency_interval` has a `<comment>` tag which says *"Number of time units for recurrence of payment."*. There's also an explaination of what all those XML tags mean.

# Answer
> 0 votes
I assume there is a question behind this question: what should I put where? I am doubtfull if an answer to your question on a list of fields will solve that for you. If my assumption is correct it might be an idea to create some user stories of what you want to achieve rather than look at a list of fields?

---
Tags: civicontribute, import
---