Case cannot be created if there are pre-assigned users

Created on 18 April 2023, about 1 year ago
Updated 19 April 2023, about 1 year ago

Drupal 9.4

There is an issue with creating cases where one or more of the timeline activities has users pre-assigned (ie assigned by default in the Case Type).

This occurs even if the case is created in the CiviCRM interface. The error log is given below (truncated) appearing to point the finger at civicrm_entity

$Fatal Error Details = array:3 [
  "message" => "Value is not a valid entity."
  "code" => null
  "exception" => InvalidArgumentException {#1179
    #message: "Value is not a valid entity."
    #code: 0
    #file: "<snip>/web/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php"
    #line: 106
    trace: {
      <snip>/web/core/lib/Drupal/Core/Entity/Plugin/DataType/EntityReference.php:106 {
        Drupal\Core\Entity\Plugin\DataType\EntityReference->setValue($value, $notify = true)
        β€Ί elseif (!is_scalar($value) || $this->getTargetDefinition()->getEntityTypeId() === NULL) {
        β€Ί   throw new \InvalidArgumentException('Value is not a valid entity.');
        β€Ί }
      }
      <snip>/web/core/lib/Drupal/Core/Field/FieldItemBase.php:125 { …}
      <snip>/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/Map.php:131 { …}
      <snip>/web/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php:179 { …}
      <snip>/web/core/lib/Drupal/Core/TypedData/TypedDataManager.php:208 { …}
      <snip>/web/core/lib/Drupal/Core/Field/FieldTypePluginManager.php:82 { …}
      <snip>/web/core/lib/Drupal/Core/Field/FieldItemList.php:41 { …}
      <snip>/web/core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php:69 { …}
      <snip>/web/core/lib/Drupal/Core/Field/FieldItemList.php:107 { …}
      <snip>/web/core/lib/Drupal/Core/Entity/ContentEntityBase.php:1088 { …}
      <snip>/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:271 { …}
      <snip>/web/modules/contrib/civicrm_entity/src/CiviEntityStorage.php:388 { …}
      <snip>/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:129 { …}
      <snip>/web/core/lib/Drupal/Core/Entity/ContentEntityStorageBase.php:94 { …}
      <snip>/web/modules/contrib/civicrm_entity/civicrm_entity.module:368 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php:283 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Utils/Hook/DrupalBase.php:73 { …}
      <snip>/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php:318 { …}
      <snip>/vendor/symfony/event-dispatcher/EventDispatcher.php:251 { …}
      <snip>/vendor/symfony/event-dispatcher/EventDispatcher.php:73 { …}
      <snip>/vendor/civicrm/civicrm-core/Civi/Core/CiviEventDispatcher.php:260 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Utils/Hook.php:348 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Activity/BAO/Activity.php:306 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/XMLProcessor/Process.php:544 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/XMLProcessor/Process.php:148 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/XMLProcessor/Process.php:121 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/XMLProcessor/Process.php:47 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/Form/Activity/OpenCase.php:321 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/Form/Case.php:400 { …}
      <snip>/vendor/civicrm/civicrm-core/CRM/Case/Form/Case.php:435 { …}
πŸ› Bug report
Status

Active

Version

3.4

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom jonhalle

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @jonhalle
  • πŸ‡¬πŸ‡§United Kingdom jonhalle
  • πŸ‡ΊπŸ‡ΈUnited States markusa

    It must be that the case is first saved without an assignee, or if assignee is assigned in a hook_civicrm_pre() implementation it is happening after CiviCRM's hook implementation is running.

    CiviCRM validates based on what the api action.validate gives it.

    It maybe possible to goto: /admin/structure/civicrm-entity/settings
    "Advanced Settings"
    Check "Disable pre/post hooks"

    See if it works without error.

    Let me know if that allows it to work.

  • πŸ‡¬πŸ‡§United Kingdom jonhalle

    Thank you @markusa. Yes that does allow it to work - though clearly it's a diagnostic step not a workaround. Does that give any more clues? Happy to do some more poking but I am not really clear on what structures in Drupal this hook is seeking to update.

    One additional thing I have noticed is that the error does not stop the case being created, albeit with only the activities up to the one with the pre-assigned user being created.

Production build 0.69.0 2024