Case cannot be created if there are pre-assigned users

Created on 18 April 2023, over 1 year ago

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)

$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 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.

  • 🇺🇸United States acacciola

    I'm seeing this continuing to persist exactly as described. Are there any updates or paths forward?

  • 🇵🇭Philippines dsdeiz

    Would there happen to be a way to reproduce this?

    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).

    I tried adding a configuration similar to this although I am unable to reproduce this - https://monosnap.com/direct/yjflNRZtIEqndOWuaPWot8mpeTJ14p.

    As a side note, there are fixes for CE 4.0.x. Might be worth a try to see if it still happens on CE 4.0.x

Production build 0.71.5 2024