Answers.Body: <p>Its a known issue in CiviCRM and is logged at <a href="https://lab.civicrm.org/dev/core/-/issues/2706" rel="nofollow noreferrer">https://lab.civicrm.org/dev/core/-/issues/2706</a></p>
  <p>Also CSV import extension don't support this(<a href="https://github.com/eileenmcnaughton/nz.co.fuzion.csvimport/issues/32" rel="nofollow noreferrer">https://github.com/eileenmcnaughton/nz.co.fuzion.csvimport/issues/32</a>).</p>
  <p>You can apply the below patch to work</p>
  <pre><code>diff --git a/CRM/Activity/Import/Parser/Activity.php b/CRM/Activity/Import/Parser/Activity.php
  index a1d3cdfa8b..3373ceabbc 100644
  --- a/CRM/Activity/Import/Parser/Activity.php
  +++ b/CRM/Activity/Import/Parser/Activity.php
  @@ -177,6 +177,11 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
           elseif (!empty($customFields[$customFieldID]) &amp;&amp; $customFields[$customFieldID]['data_type'] == 'Boolean') {
             $params[$key] = CRM_Utils_String::strtoboolstr($val);
           }
  +        elseif (!empty($customFields[$customFieldID]) &amp;&amp; $customFields[$customFieldID]['serialize'] == TRUE) {
  +          $val = trim($val);
  +          $val = str_replace('|', ',', $val);
  +          $params[$key] = explode(',', $val);
  +        }
         }
         elseif ($key === 'activity_date_time') {
           $params[$key] = CRM_Utils_Date::formatDate($val, $dateType);
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-26T13:33:19.730Z
Answers.Text: That's perfect - thanks Pradeep - I can now import multiple options in an options group attached to activities.
Answers.UserDisplayName: Marsh
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-01-25T19:20:36.147Z
Answers.LastActivityDate: 2022-01-25T19:38:21.907Z
Answers.LastEditDate: 2022-01-25T19:38:21.907Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm trying to import a set of Multi Select Options on a Custom Field that's attached to Activities, but I can't find a way to do it.</p>
  <p>I've tried replacing the csv field with the label strings, the values, comma separating both of these, space separating them and quoting them (with all of the above) but cannot get the multi select options to import.</p>
  <p>I've moved on to the API - but can't find how to pull (or set) customValue fields for activities.</p>
  <p>Finally - Mysql. I can insert a created string directly by placing the values into the civicrm_value_xxx_id table against the entity_id (activity id), separated by <code>. CHAR(01) .</code> statements, as in (for a single 'test' line on a local install):</p>
  <pre><code>UPDATE civicrm_value_activity_opti_4 
  SET option_group_field_7 = CONCAT(CHAR(01), '1', CHAR(01) , '10', CHAR(01), '100', CHAR(01)) 
  WHERE entity_id = 625;
  
  </code></pre>
  <p>...but this seems laborious and like there should be a more simple way to insert multiple selected options into an activity custom field (as it's going to require a bit of scripting to pick up the details of each of the (30000?) activities.</p>
  <p>Does anyone here know what I'm missing, or if there is a more straightforward way to import the multi-select options?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-25T17:06:43.430Z
Comments.Text: did you try with values instead of labels?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-25T20:24:42.133Z
Comments.Text: I did indeed, but had no joy :(
Comments.UserDisplayName: Marsh
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-25T21:21:08.943Z
Comments.Text: did you try the patch below?
Comments.UserDisplayName: Pradeep Nayak
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2022-01-27T20:28:59.650Z
Comments.Text: I did. It was magnificent. Thank you :)
Comments.UserDisplayName: Marsh
Tags: <custom-fields><data-import><multiple-choice>
Title: importing multi select options into Activity custom fields
ThreadText: # importing multi select options into Activity custom fields
  
  (Asked by: username_0 on 2022-01-25)
  
  I'm trying to import a set of Multi Select Options on a Custom Field that's attached to Activities, but I can't find a way to do it.
  I've tried replacing the csv field with the label strings, the values, comma separating both of these, space separating them and quoting them (with all of the above) but cannot get the multi select options to import.
  I've moved on to the API - but can't find how to pull (or set) customValue fields for activities.
  Finally - Mysql. I can insert a created string directly by placing the values into the civicrm_value_xxx_id table against the entity_id (activity id), separated by . CHAR(01) . statements, as in (for a single 'test' line on a local install):
  UPDATE civicrm_value_activity_opti_4 
  SET option_group_field_7 = CONCAT(CHAR(01), '1', CHAR(01) , '10', CHAR(01), '100', CHAR(01)) 
  WHERE entity_id = 625;
  
  
  ...but this seems laborious and like there should be a more simple way to insert multiple selected options into an activity custom field (as it's going to require a bit of scripting to pick up the details of each of the (30000?) activities.
  Does anyone here know what I'm missing, or if there is a more straightforward way to import the multi-select options?
  
  **Tags:** custom-fields, data-import, multiple-choice
  
  > **Comments:**
  > **username_1**: did you try with values instead of labels?  
  > **username_0**: I did indeed, but had no joy :(  
  > **username_1**: did you try the patch below?  
  > **username_0**: I did. It was magnificent. Thank you :)  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-01-25. Score: 1 | Accepted answer
  
  Its a known issue in CiviCRM and is logged at https://lab.civicrm.org/dev/core/-/issues/2706
  Also CSV import extension don't support this(https://github.com/eileenmcnaughton/nz.co.fuzion.csvimport/issues/32).
  You can apply the below patch to work
  diff --git a/CRM/Activity/Import/Parser/Activity.php b/CRM/Activity/Import/Parser/Activity.php
  index a1d3cdfa8b..3373ceabbc 100644
  --- a/CRM/Activity/Import/Parser/Activity.php
  +++ b/CRM/Activity/Import/Parser/Activity.php
  @@ -177,6 +177,11 @@ class CRM_Activity_Import_Parser_Activity extends CRM_Activity_Import_Parser {
           elseif (!empty($customFields[$customFieldID]) && $customFields[$customFieldID]['data_type'] == 'Boolean') {
             $params[$key] = CRM_Utils_String::strtoboolstr($val);
           }
  +        elseif (!empty($customFields[$customFieldID]) && $customFields[$customFieldID]['serialize'] == TRUE) {
  +          $val = trim($val);
  +          $val = str_replace('|', ',', $val);
  +          $params[$key] = explode(',', $val);
  +        }
         }
         elseif ($key === 'activity_date_time') {
           $params[$key] = CRM_Utils_Date::formatDate($val, $dateType);
  
  > **Comments:**
  > **username_0**: That's perfect - thanks Pradeep - I can now import multiple options in an options group attached to activities.  
  
  ---
  
  