CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • Must have same label as name for case types?
Pages: [1]

Author Topic: Must have same label as name for case types?  (Read 1051 times)

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Must have same label as name for case types?
July 22, 2011, 01:51:55 pm
Hi!

When I had set up my first CiviCase configuration I could create cases but they "disappeared" if I didn't create an activity for that case. I discovered that my Open Case activity was never created. I read in some post here that all the testing was done on cases with timelines so I added a standard timeline. Then I couldn't even create a case. This is the backtrace:
Code: [Select]
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/Error.php, backtrace, 291
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, fatal, 448
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, getMaxInstance, 288
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, isActivityPresent, 407
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, createActivity, 140
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, processStandardTimeline, 116
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/XMLProcessor/Process.php, process, 58
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/Form/Activity/OpenCase.php, run, 298
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/Form/Case.php(394) : eval()'d code, endPostProcess, 1
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/Form/Case.php, eval, 394
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/Form.php, postProcess, 250
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php, mainProcess, 153
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/QuickForm/Action/Upload.php, realPerform, 130
/var/www/drupal-7.0/sites/all/modules/civicrm/packages/HTML/QuickForm/Controller.php, perform, 203
/var/www/drupal-7.0/sites/all/modules/civicrm/packages/HTML/QuickForm/Page.php, handle, 103
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/Controller.php, handle, 284
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/Page/Tab.php, run, 180
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Case/Page/Tab.php, edit, 212
/var/www/drupal-7.0/sites/all/modules/civicrm/CRM/Core/Invoke.php, run, 224
/var/www/drupal-7.0/sites/all/modules/civicrm/drupal/civicrm.module, invoke, 385
, civicrm_invoke,
/var/www/drupal-7.0/includes/menu.inc, call_user_func_array, 501
/var/www/drupal-7.0/index.php, menu_execute_active_handler, 22

So I noticed that the isActivityPresent() is calling getCaseType() without the second argument wich means it's fetching the label of the case type. I use swedish labels but try to stick to english names (just because some swedish letters often leads to issues in programming). So in my case the result is that getMaxInstance() always fails because it can find my case type.

My fix is to pass the string "name" as the second argument to getCaseType which tells it to fetch the name of the case type (instead of the label) and everything works. But maybe I am missing something here. Haven't anyone tried to use labels that aren't the same as the corresponding names before?

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Re: Must have same label as name for case types?
July 22, 2011, 02:00:20 pm
But you still need a to define an ActivitySet with the name Open Case otherwise the activity will not be created. So I now check if the ActivitySets tag is defined and if not create the Open Case activity. I think this is good because I don't need a timeline for some of my case types. Here is my patch:

Code: [Select]
Index: CRM/Case/XMLProcessor/Process.php
===================================================================
--- CRM/Case/XMLProcessor/Process.php (revision 35477)
+++ CRM/Case/XMLProcessor/Process.php (working copy)
@@ -100,6 +100,18 @@
                     }
                 }
             }
+            // If no timeline (ActivitySets) create the open case activity here
+            if ( !isset($xml->ActivitySets) ) {
+                foreach ( $xml->ActivityTypes as $activityTypesXML ) {
+                    foreach ( $activityTypesXML->ActivityType as $activityTypeXML ) {
+                        $name = (string ) $activityTypeXML->name;
+                        if ( $name == 'Open Case' ) {
+                            $activityTypeXML->status = 'Completed';
+                            $this->createActivity( $activityTypeXML, $params );
+                        }
+                    }
+                }
+            }
         }
         
         if ( 'Change Case Start Date' ==
@@ -284,7 +296,7 @@
         $count       = CRM_Core_DAO::singleValueQuery( $query, $sqlParams );
         
         // check for max instance
-        $caseType    = CRM_Case_BAO_Case::getCaseType( $params['caseID'] );
+        $caseType    = CRM_Case_BAO_Case::getCaseType( $params['caseID'], 'name' );
         $maxInstance = self::getMaxInstance( $caseType, $params['activityTypeName'] );
 
         return $maxInstance ? ($count < $maxInstance ? false : true) : false;

I have tested this on my installation and it works like charm - with or without timelines and when label != name. But a bit ugly with the hard coded status ('Completed') but I saw that there's a lot of hard coded activity types and other stuff in this module. Is this a good solution?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Must have same label as name for case types?
July 24, 2011, 08:11:14 am
I've had installs in the past where label and name are different. Also in the sample config they are different. So it should work if they are different.

For the Open Case I think your solution might be ok. The audit report on manage case probably won't work without an activity set defined, and I'm wondering does it affect Print Case?

gastrit

  • I post occasionally
  • **
  • Posts: 60
  • Karma: 2
  • CiviCRM version: 4.2.2
  • CMS version: 7.8
  • MySQL version: 5.1.41
  • PHP version: 5.3.2
Re: Must have same label as name for case types?
July 27, 2011, 07:05:54 am
Ok!

Maybe the solution is to have an activity set with the open case but then I still shouldn't have to write it in the config file. I have seen some discussions about the case config files so I guess things will change anyway.


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using CiviCase (Moderator: Dave Greenberg) »
  • Must have same label as name for case types?

This forum was archived on 2017-11-26.