Answers.Body: <p>I ended up using a drush script to import data into custom multi record fields:</p>
  <p>create file <code>import-script.scr</code>
  run it as: <code>drush scr import-script.scr</code></p>
  <p>script:</p>
  <pre><code>&lt;?php
  
  $file = '/var/www/html/sites/default/scripts/civicrm_value_import.csv';
  
  $fh = fopen($file, 'r');
  
  while ($row = fgetcsv($fh)) {
  
    $contact_id = $row[8];
    if (empty($contact_id)) {
       continue;
    }
  
    // Build array for new data
    $import = [
      'entity_id' =&gt; $contact_id,
      'discharge_reason_329' =&gt; $row[14],
      'primary_presenting_problem_335' =&gt; $row[15],
      'principal_diagnosis_336' =&gt; $row[16],
      'diagnosis_2_337' =&gt; $row[17],
      'diagnosis_3_338' =&gt; $row[18],
      'opioid_dependency_339' =&gt; $row[19]
    ];
    if (!empty($row[11])) {
      $import += ['referral_date_331' =&gt; $row[11]];
    }
    if (!empty($row[12])) {
      $import += ['enrolment_date_332' =&gt; $row[12]];
    }
    if (!empty($row[13])) {
      $import += ['discharge_date_333' =&gt; $row[13]];
    }         
    if (!empty($row[21])) {
      $import += ['initiation_date_341' =&gt; $row[21]];
    }
    
    //  print_r([$import]);
  
    // Insert
    db_insert('civicrm_value_raam_66')
      -&gt;fields($import)
      -&gt;execute();
  
    // For testing one row
    // break;
  
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-04T19:53:54.403Z
Answers.LastActivityDate: 2020-12-04T19:53:54.403Z
Answers.UserDisplayName: KarinG - Semper IT
Answers.Body: <p>You can import multi-value custom fields through the API, including the <a href="https://civicrm.org/extensions/api-csv-import-gui" rel="nofollow noreferrer">API CSV Import GUI</a>.  You use the <code>CustomValue</code> API; you can also use <a href="https://civicrm.stackexchange.com/q/4723/12">the command-line CSV import tool</a> or even <code>drush</code>.</p>
  <p>Your contact ID field should be imported as <code>entity_id</code>.  If the custom field ID is &quot;4&quot;, then import to <code>custom_4</code>.</p>
  <p>As an example - if your field set is called &quot;schools attended&quot;, with custom fields &quot;school&quot;  (custom field ID 7) and &quot;degree&quot; (custom field ID 8) for a contact with an ID of 123, your data may look like this:</p>
  <pre><code>entity_id | custom_7                 | custom_8
  123       | University of Wisconsin  | BA
  123       | Rutgers University       | MA
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-03T22:34:16.240Z
Answers.Text: Trying this again and not possible via the API CSV Import GUI. The only select options I have are "Entity ID" and "- do not import -" -> I can't map any of my custom_ fields to any custom_ fields. This site is running ESR. I was looking for a UI option (so an admin could do it) but going command line now :-)
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-04T18:10:01.223Z
Answers.Text: Hmm - in API Explorer you can select "Other" instead of "Do Not Import".  So much for my confidently incorrect answer :)
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-04T19:40:02.433Z
Answers.Text: I don’t get an Other option in API CSV import -> I ended up writing a little drush script - will post that here for completeness 
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-02T19:32:21.997Z
Answers.LastActivityDate: 2020-12-02T19:32:21.997Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>If you have complicated import needs - for instance, you need to import multi-value custom fields as part of a larger import - you may want to consider the &quot;Advanced Import-Form Processor&quot; approach.</p>
  <p>I really need to write docs up, but in general:</p>
  <ul>
  <li>Install <a href="https://civicrm.org/extensions/form-processor" rel="nofollow noreferrer">Form Processor</a>.</li>
  <li>Create a new form processor instance.  Each &quot;input&quot; should correspond to a column in your source data.</li>
  <li>When creating your actions, the &quot;Update Individual&quot; action won't import multi-value custom fields - but the &quot;Contact: Update Custom Data&quot; action will.</li>
  <li>Test it out using the &quot;Try Out&quot; functionality to ensure it works as expected.
  Now the magic bit - how to use this as an import instead of for form submissions?</li>
  <li>Install <a href="https://civicrm.org/extensions/advanced-import" rel="nofollow noreferrer">Advanced Import</a>.</li>
  <li>Install <a href="https://github.com/MegaphoneJon/advimportformprocessor" rel="nofollow noreferrer">Advanced Import Form Processor</a>.</li>
  </ul>
  <p>Advanced Import gives you an import UI; Advanced Import Form Processor lets you use a Form Processor instance to process each line in your file.  Advanced Import has some limitations (e.g. it doesn't handle large files well) and Form Processor is relatively slow - but you can create pretty much any import you need without coding by using these three extensions together.  <em>And</em> it has an end-user focused UI.  Much like Views or Webform, an admin can create something complex, but the end result is usable by end users.</p>
  <p>Below is a screenshot of a Form Processor instance I created.  I was given a list of students with their schools and related information.  I was able to:</p>
  <ul>
  <li>Create students if they didn't exist, or use existing contacts if they did (<a href="https://docs.civicrm.org/xcm/en/latest/" rel="nofollow noreferrer">XCM</a> integrates with Form Processor for very fine-grained duplicate matching).</li>
  <li>Create the school if necessary.</li>
  <li>Create a &quot;Student/School&quot; relationship that filled in relationship custom fields &quot;Major&quot; and &quot;Degree&quot;.  Note that you can import relationships with standard import, but can NOT import to relationship custom fields.</li>
  <li>Imported alumni information, which is stored in a multi-record custom field group.</li>
  </ul>
  <p><a href="https://i.sstatic.net/E5WAG.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/E5WAG.png" alt="enter image description here" /></a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-02T19:51:06.087Z
Answers.LastActivityDate: 2020-12-02T19:51:06.087Z
Answers.UserDisplayName: Jon G - Megaphone Tech
Answers.Body: <p>Steps:</p>
  
  <ol>
  <li>Contacts > Import Contacts</li>
  <li>Click the help ? at the end of: "The Import Wizard.... them here."</li>
  <li>Click the link on here at the end of: "If you need to import Multi-value Custom Data for contacts.... from here: /civicrm/import/custom?reset=1 .</li>
  </ol>
  
  <p>You should see the multi-record field to import</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-16T00:23:29.400Z
Answers.Text: May be helpful to include this link in your answer so people can get to it more easily ie /civicrm/import/custom?reset=1
Answers.UserDisplayName: petednz - fuzion
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-21T10:13:14.153Z
Answers.Text: Thanks so much Sanjay... I would never have found it!   
  Agree with petednz - the link to multi record import needs to be much more obvious on Civi itself
Answers.UserDisplayName: Catherine
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-21T04:01:13.133Z
Answers.Text: can anybody in this thread help me with this question? https://civicrm.stackexchange.com/questions/19107/help-needed-in-importing-multi-value-custom-fields
Answers.UserDisplayName: Parthibaraj Rajasekar
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-12-03T23:38:26.210Z
Answers.Text: I can't get this to work for dates :-(
Answers.UserDisplayName: KarinG - Semper IT
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2015-07-15T22:36:52.540Z
Answers.LastActivityDate: 2019-02-01T12:22:27.567Z
Answers.LastEditDate: 2019-02-01T12:22:27.567Z
Answers.UserDisplayName: Sanjay Jain
Body: <p>I am trying to import records to a custom multi-record set of fields.
  I read somewhere that it was a new feature for 4.5.8 but now for the life of me I cannot find where I read it - pretty sure it was the release notes, but may have got the version wrong.</p>
  
  <p>Would appreciate a pointer in the right direction. (we are currently on 4.6.4)</p>
  
  <p>Many thanks</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-07-15T16:37:20.940Z
Comments.Text: Note this the import relates to multi-record sets attached to a contact record
Comments.UserDisplayName: Catherine
Tags: <import>
Title: How to import to multi-record set custom fields
ThreadText: # How to import to multi-record set custom fields
  
  (Asked by: username_0 on 2015-07-15)
  
  I am trying to import records to a custom multi-record set of fields.
  I read somewhere that it was a new feature for 4.5.8 but now for the life of me I cannot find where I read it - pretty sure it was the release notes, but may have got the version wrong.
  
  Would appreciate a pointer in the right direction. (we are currently on 4.6.4)
  
  Many thanks
  
  **Tags:** import
  
  > **Comments:**
  > **username_0**: Note this the import relates to multi-record sets attached to a contact record  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_3 on 2015-07-15. Score: 5 | Accepted answer
  
  Steps:
  
  1. Contacts > Import Contacts
  2. Click the help ? at the end of: "The Import Wizard.... them here."
  3. Click the link on here at the end of: "If you need to import Multi-value Custom Data for contacts.... from here: /civicrm/import/custom?reset=1 .
  
  You should see the multi-record field to import
  
  > **Comments:**
  > **username_4**: May be helpful to include this link in your answer so people can get to it more easily ie /civicrm/import/custom?reset=1  
  > **username_0**: Thanks so much Sanjay... I would never have found it!    Agree with petednz - the link to multi record import needs to be much more obvious on Civi itself  
  > **username_5**: can anybody in this thread help me with this question? https://civicrm.stackexchange.com/questions/19107/help-needed-in-importing-multi-value-custom-fields  
  > **username_1**: I can't get this to work for dates :-(  
  
  ---
  
  ### Answer by username_1 on 2020-12-04. Score: 1
  
  I ended up using a drush script to import data into custom multi record fields:
  create file import-script.scr
  run it as: drush scr import-script.scr
  script:
   $contact_id,
      'discharge_reason_329' => $row[14],
      'primary_presenting_problem_335' => $row[15],
      'principal_diagnosis_336' => $row[16],
      'diagnosis_2_337' => $row[17],
      'diagnosis_3_338' => $row[18],
      'opioid_dependency_339' => $row[19]
    ];
    if (!empty($row[11])) {
      $import += ['referral_date_331' => $row[11]];
    }
    if (!empty($row[12])) {
      $import += ['enrolment_date_332' => $row[12]];
    }
    if (!empty($row[13])) {
      $import += ['discharge_date_333' => $row[13]];
    }         
    if (!empty($row[21])) {
      $import += ['initiation_date_341' => $row[21]];
    }
    
    //  print_r([$import]);
  
    // Insert
    db_insert('civicrm_value_raam_66')
      ->fields($import)
      ->execute();
  
    // For testing one row
    // break;
  
  }
  
  
  ---
  
  ### Answer by username_2 on 2020-12-02. Score: 1
  
  You can import multi-value custom fields through the API, including the API CSV Import GUI.  You use the CustomValue API; you can also use the command-line CSV import tool or even drush.
  Your contact ID field should be imported as entity_id.  If the custom field ID is "4", then import to custom_4.
  As an example - if your field set is called "schools attended", with custom fields "school"  (custom field ID 7) and "degree" (custom field ID 8) for a contact with an ID of 123, your data may look like this:
  entity_id | custom_7                 | custom_8
  123       | University of Wisconsin  | BA
  123       | Rutgers University       | MA
  
  > **Comments:**
  > **username_1**: Trying this again and not possible via the API CSV Import GUI. The only select options I have are "Entity ID" and "- do not import -" -> I can't map any of my custom_ fields to any custom_ fields. This site is running ESR. I was looking for a UI option (so an admin could do it) but going command line now :-)  
  > **username_2**: Hmm - in API Explorer you can select "Other" instead of "Do Not Import".  So much for my confidently incorrect answer :)  
  > **username_1**: I don’t get an Other option in API CSV import -> I ended up writing a little drush script - will post that here for completeness   
  
  ---
  
  ### Answer by username_2 on 2020-12-02. Score: 1
  
  If you have complicated import needs - for instance, you need to import multi-value custom fields as part of a larger import - you may want to consider the "Advanced Import-Form Processor" approach.
  
  I really need to write docs up, but in general:
  
  * Install [Form Processor](https://civicrm.org/extensions/form-processor).
  * Create a new form processor instance. Each "input" should correspond to a column in your source data.
  * When creating your actions, the "Update Individual" action won't import multi-value custom fields - but the "Contact: Update Custom Data" action will.
  * Test it out using the "Try Out" functionality to ensure it works as expected.
    Now the magic bit - how to use this as an import instead of for form submissions?
  * Install [Advanced Import](https://civicrm.org/extensions/advanced-import).
  * Install [Advanced Import Form Processor](https://github.com/MegaphoneJon/advimportformprocessor).
  
  Advanced Import gives you an import UI; Advanced Import Form Processor lets you use a Form Processor instance to process each line in your file. Advanced Import has some limitations (e.g. it doesn't handle large files well) and Form Processor is relatively slow - but you can create pretty much any import you need without coding by using these three extensions together. *And* it has an end-user focused UI. Much like Views or Webform, an admin can create something complex, but the end result is usable by end users.
  
  Below is a screenshot of a Form Processor instance I created. I was given a list of students with their schools and related information. I was able to:
  
  * Create students if they didn't exist, or use existing contacts if they did ([XCM](https://docs.civicrm.org/xcm/en/latest/) integrates with Form Processor for very fine-grained duplicate matching).
  * Create the school if necessary.
  * Create a "Student/School" relationship that filled in relationship custom fields "Major" and "Degree". Note that you can import relationships with standard import, but can NOT import to relationship custom fields.
  * Imported alumni information, which is stored in a multi-record custom field group.
  
  [![enter image description here](https://i.sstatic.net/E5WAG.png)](https://i.sstatic.net/E5WAG.png)
  
  
  ---
  
  