I've provided a PR to format date, datetime and money values on search export for contributions and others: https://github.com/civicrm/civicrm-core/pull/27862. @marcusm you may test this one, if it does solve this issue for you.
To workaround this, I would rename the group (removing the trailing underscore) by updating the database fields
name
in civicrm_custom_group
name
in civicrm_mapping_field
Is this OK or am I missing something?
I have tested it and I can confirm it:
group label | group name | field label | field name | error on import |
---|---|---|---|---|
Foo | Foo |
Test | Test |
no |
Foo | Foo |
Test (Info) | Test_Info_ |
no |
Foo | Foo |
(Info) | _Info_ |
no |
Foo (Bar) | Foo_Bar_ |
Test | Test |
yes |
Foo (Bar) | Foo__Bar |
Test | Test |
yes |
Foo (Bar | Foo_bar |
Test | Test |
no |
Foo (Bar | Foo_bar |
(Info) | _Info_ |
no |
The problem does not affect all custom fields, but depends on the group name. As soon as this ends with an underscore (e.g. because of a bracket in the label) or has double underscore, the error occurs. It doesn't matter if the field name itself ends or starts with an underscore.
I'm not aware of field names with dots. I've checked all with the API. They just contain letters and underscores.
When importing contributions with field mappings to a custom field, the process fails after continuing from step 2 of 3.
Regardless of the provided CSV data, the process fails with:
TypeError: CRM_Import_Parser::getFieldMetadata(): Return value must be of type array, null returned in CRM_Import_Parser->getFieldMetadata() (line 1768 of /var/www/html/vendor/civicrm/civicrm-core/CRM/Import/Parser.php).
CRM_Import_Parser->getFieldMetadata('Zu_belastendes_Konto.nur_anstehende_Zuwendungen._IBAN') (Line: 165)
CRM_Contribute_Import_Parser_Contribution->getMappedRow(Array) (Line: 221)
CRM_Contribute_Import_Parser_Contribution->validateValues(Array) (Line: 2551)
CRM_Import_Parser->validateRow(Array) (Line: 1842)
CRM_Import_Parser->validate() (Line: 90)
CRM_Import_Form_MapField->postProcess() (Line: 612)
CRM_Core_Form->mainProcess() (Line: 144)
CRM_Core_StateMachine->perform(Object, 'next', 'Next') (Line: 43)
CRM_Core_QuickForm_Action_Next->perform(Object, 'next') (Line: 203)
HTML_QuickForm_Controller->handle(Object, 'next') (Line: 103)
HTML_QuickForm_Page->handle('next') (Line: 355)
CRM_Core_Controller->run(Array, NULL) (Line: 319)
CRM_Core_Invoke::runItem(Array) (Line: 69)
CRM_Core_Invoke::_invoke(Array) (Line: 36)
CRM_Core_Invoke::invoke(Array) (Line: 88)
Drupal\civicrm\Civicrm->invoke(Array) (Line: 83)
Drupal\civicrm\Controller\CivicrmController->main(Array, '')
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 580)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 169)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 81)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 718)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
I've tested latest versions and can reproduce it in 5.60 and later. It was probably caused with changes in Update Contribution Import to use apiv4 field names, prior to adding hooks. The way of getting custom fields available for import has changed, which leads to different field keys respectively option values. Previously you got the short version "custom_xy", now you get a long database field name like one.
The import parser can't find related field meta data regarding to those keys.
I'm not sure, if those key names provided by the API are intended and therefor can't provide a PR.
I'm not sure, as they all revolve around export and formatting and may have the same cause. I would leave that decision to more experienced CiviCRM developers.
Same result (unformatted amounts), when using the search kit: CiviCRM_Contribution_Search_2_.csv.
How did you export the contributions? If I go to https://dmaster.demo.civicrm.org/ and
...I'm getting a CSV with unformatted amounts: CiviCRM_Contribution_Search.csv
I've figured out, that this is not a general CSV export problem. If you create a custom field of type money for contacts and export the contact including this field, the amount is getting formatted along with respect to the localization configuration. So the issue does not affect all entity types (possibly only contributions).
I can confirm this issue with CiviCRM 5.58.0. It's a quite annoying problem for our accounting, because contribution amounts are thereby multiplied by 100, so to speak. E.g. 10.00 becomes 1000, because in German the dot is not the regular decimal delimiter.
I've found some related tickets, which have been fixed in the past year:
Referring to https://github.com/civicrm/civicrm-drupal/pull/495
Philipp Michael (4d0528cc) at 18 Jul 07:12
docs: describe bootstrap in Drupal 9
I've made a merge request for a possible fix. Please have a look. It's my first one here
This is a fix for #27.
I'm not sure why contact_id
needs to be part of the message params but I think it should be a string instead of an array.
Philipp Michael (40c858c4) at 01 Jul 09:34
fix: prevent type error on send email
When sending an email via Email API as an action of a CiviRule I get the error:
TypeError: strtolower(): Argument #1 ($string) must be of type string, array given in strtolower() (Line 1408 von /var/www/foo/web/sites/all/modules/civicrm/CRM/Core/DAO.php).
It seems to be caused by the token replacement process in order to send the email. The contact ID is passed as an array instead of a string.
System Environment
PHP: 8.0.19
Email API: 2.8
CiviCRM: 5.50.2
CiviRules: 2.43
Drupal: 7.90