Skip to content
Snippets Groups Projects
Closed Upgrading to 5.24.1 custom field not saved for Case when submitted from webform
  • View options
  • Upgrading to 5.24.1 custom field not saved for Case when submitted from webform

  • View options
  • Closed Issue created by Pradeep Nayak

    To Replicate: Create a webform and enable civicase with custom field. After submitting the webform a new case is created but the custom fields are blank.

    This was working until 5.22.x and than update to DB/ packages in 5.23 broke this functionality. This cannot be replicated when case is created from UI but can be replicated by writing code eg

        $result = civicrm_api3('Case', 'create', [
          'contact_id' => 202,
          'case_type_id' => "housing_support",
          'subject' => "test",
        ])['id'];
        $cust = array(
            '19' => array(
              '-1' => array(
                'id' => '',
                'value' => '344',
                'type' => 'Money',
                'custom_field_id' => '19',
                'custom_group_id' => '13',
                'table_name' => 'civicrm_value_reportable_co_13',
                'column_name' => 'reportable_cost_19',
                'file_id' => '',
                'is_multiple' => '0',
              )
            )
        );
        CRM_Core_BAO_CustomValueTable::store($cust, 'civicrm_case', $result);

    Digging into the code found that the entry civicrm_value_reportable_co_13 table does get created but isn't shown. I guess this is because the transaction is started but not committed. Below patch fixes my problem (which removes Transaction code) but I guess its not ideal solution.

    diff --git a/Civi/CCase/Events.php b/Civi/CCase/Events.php
    index 114875f17e..f76c92c267 100644
    --- a/Civi/CCase/Events.php
    +++ b/Civi/CCase/Events.php
    @@ -78,12 +78,10 @@ class Events {
       public static function fireCaseChangeForRealz($caseIds) {
         foreach ((array) $caseIds as $caseId) {
           if (!isset(self::$isActive[$caseId])) {
    -        $tx = new \CRM_Core_Transaction();
             self::$isActive[$caseId] = 1;
             $analyzer = new \Civi\CCase\Analyzer($caseId);
             \CRM_Utils_Hook::caseChange($analyzer);
             unset(self::$isActive[$caseId]);
    -        unset($tx);
           }
         }
       }

    Linked items ... 0

  • Activity

    • All activity
    • Comments only
    • History only
    • Newest first
    • Oldest first
    Loading Loading Loading Loading Loading Loading Loading Loading Loading Loading