3

I have a Drupal/CiviCRM instance (v 5.19.3) that I have inherited. It seems much of the custom work was done prior to version 4.6. And then it was upgraded to 5.19.3 without updating the customizations. One customization is the case types. They appear in two locations, a Civi extension (xml/case/*.xml) and under custom templates (sites/all/custom_templates/CRM/Case/xml/configuration) - yes, the directory setting for the custom templates is correctly set. Both directories contain the same files, which at this point are customized versions of the Civi core HRD xml files (sites/all/modules/civicrm/CRM/Case/xml/HRD).

When I attmept to load the Civi Case Types page (https://[site]/civicrm/admin/options/case_type?reset=1), I am getting an fatal error. This happens regardless of whether I attempt to load the types from the menu or using the API.

  • civicrm/ajax/rest?entity=CaseType&action=get&json=%7B%22options%22%3A%7B%22limit%22%3A0%7D%7D - message: $Fatal Error Details = Array ( [message] => [code] => )

Back Trace:

$backTrace = #0 /var/www/instance/sites/all/modules/civicrm/CRM/Core/Error.php(343): CRM_Core_Error::backtrace("backTrace", TRUE) #1 /var/www/instance/sites/all/modules/civicrm/CRM/Core/DAO.php(1195): CRM_Core_Error::fatal() #2 /var/www/instance/sites/all/modules/civicrm/CRM/Case/XMLRepository.php(96): CRM_Core_DAO::getFieldValue("CRM_Case_DAO_CaseType", "", "definition", "name") #3 /var/www/instance/sites/all/modules/civicrm/api/v3/CaseType.php(102): CRM_Case_XMLRepository->retrieve("") #4 /var/www/instance/sites/all/modules/civicrm/api/v3/CaseType.php(81): _civicrm_api3_case_type_get_formatResult((Array:4), (Array:5)) #5 /var/www/instance/sites/all/modules/civicrm/Civi/API/Provider/MagicFunctionProvider.php(101): civicrm_api3_case_type_get((Array:3)) #6 /var/www/instance/sites/all/modules/civicrm/Civi/API/Kernel.php(168): Civi\API\Provider\MagicFunctionProvider->invoke((Array:9)) #7 /var/www/instance/sites/all/modules/civicrm/Civi/API/Kernel.php(99): Civi\API\Kernel->runRequest((Array:9)) #8 /var/www/instance/sites/all/modules/civicrm/api/api.php(23): Civi\API\Kernel->runSafe("CaseType", "get", (Array:3), NULL) #9 /var/www/instance/sites/all/modules/civicrm/CRM/Utils/REST.php(316): civicrm_api("CaseType", "get", (Array:3)) #10 /var/www/instance/sites/all/modules/civicrm/CRM/Utils/REST.php(566): CRM_Utils_REST::process((Array:3), (Array:3)) #11 /var/www/instance/sites/all/modules/civicrm/CRM/Core/Invoke.php(256): CRM_Utils_REST::ajax() #12 /var/www/instance/sites/all/modules/civicrm/CRM/Core/Invoke.php(84): CRM_Core_Invoke::runItem((Array:12)) #13 /var/www/instance/sites/all/modules/civicrm/CRM/Core/Invoke.php(52): CRM_Core_Invoke::_invoke((Array:3)) #14 /var/www/instance/sites/all/modules/civicrm/drupal/civicrm.module(444): CRM_Core_Invoke::invoke((Array:3)) #15 /var/www/instance/includes/menu.inc(517): civicrm_invoke("ajax", "rest") #16 /var/www/instance/index.php(21): menu_execute_active_handler() #17 {main}

The definitions for the Case Types in the database are set to NULL. Is the definition value supposed to be an array based on the XML activity types listed in the xml file? Note that it seems the old names/titles were only slightly different. At this point there are cases for each of the IDs listed below. All of the activity types listed in the xml's are the same for each case and the client would like to consoldiate all the Cases under one Case Type. The Civi extension calls a hook_civicrm_caseTypes when it is enabled and disabled. And though this hook is being called, it only updates is_active field to true or false based on being enabled or disabled (currently, the ones it updates have is_active set to 0, when enabled they are 1). It does not update the definitions.

+----+------------------------------+------------------------------+-------------+-----------+-------------+--------+------------+
| id | name                         | title                        | description | is_active | is_reserved | weight | definition |
+----+------------------------------+------------------------------+-------------+-----------+-------------+--------+------------+
|  1 | Civil And Political          | Civil And Political          | NULL        |         1 |           0 |      1 | NULL       |
|  2 | Economic Social And Cultural | Economic Social And Cultural | NULL        |         1 |           0 |      2 | NULL       |
|  3 | Gender Issues                | Gender Issues                | NULL        |         1 |           0 |      4 | NULL       |
|  4 | LGBT                         | LGBT                         | NULL        |         1 |           0 |      5 | NULL       |
|  5 |                              | Environmental                | NULL        |         0 |           0 |      3 | NULL       |
|  6 | CivilAndPolitical            | Civil And Political          | NULL        |         0 |           1 |      1 | NULL       |
|  7 | EconomicSocialAndCultural    | Economic Social And Cultural | NULL        |         0 |           1 |      1 | NULL       |
|  8 | Environmental                | Environmental                | NULL        |         0 |           1 |      1 | NULL       |
|  9 | GenderIssues                 | Gender Issues                | NULL        |         0 |           1 |      1 | NULL       |
+----+------------------------------+------------------------------+-------------+-----------+-------------+--------+------------+

Is there a way to insert the Case Type definitions from the existing xmls? Is this the approach you would use or do you have another suggestion for how I should approach this problem? How can I get the Case Types to load in the UI?

I appreciate your help.

0
4

When stored in files the definition field is null.

See also What are the pros and cons of using external xml files for CiviCase configuration?

But if you just want to consolidate all under one type, just turn off the hook extension and run a SQL statement update civicrm_case set case_type_id=1, and then delete all the case types except id 1 and set is_active manually to 1 for it. Then configure the activities for the type in the UI.

Also move all the xml files out of the way.

3
  • 3
    Thanks for responding, @Demerit, I really appreciate it. Worked like a charm! I ended up using 9 instead of 1 because the name with the spaces was still causing issues and I was unable to load the UI. Refreshed db, followed you directions and set everything to ID 9 instead. Worked like a dream and I was able to create a new generic case type. Thank you, again. Update: unfortunately, I don't have enough of a rep to upvote your answer but my feedback was recorded. Jun 22 at 1:29
  • Great, glad it worked out.
    – Demerit
    Jun 22 at 1:30
  • add a couple of more comments here so we can upvote them (if they are nice comments)
    – petednz - fuzion
    Jun 22 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.