0

I am trying to import data into a multi-value link field from a JSON source using Migrate Tools. I think I should be able to do this without writing a custom plugin, but so far nothing is working. My JSON looks like this:

[
 {
  "first_name": "Joe"
  "last_name": "Smith"
  "departments": [
     {
       "department_name": "Mail room"
       "department_url": "https://myoffice.com/mailroom"
     },
     {
       "department_name": "Receiving"
       "department_url": "https://myoffice.com/receiving"
     }
   ],
 },
 { . . . etc }
]

The department_name and department_url values would be the title value and uri value for a multi-value link field. I have tried using the sub_process plugin by configuring the migration config this way:

- name: department_data
  label: "Department data"
  selector: departments

...

process:
   field_department_link:
      plugin: sub_process
      source: department_data
      process:
        'field_department_link/title': department_name
        'field_department_link/uri': department_url

I should note that this migration config is working overall, as I have a number of straight-up text fields that are importing just fine, so I know the issue is specific to how I'm trying to handle this particular field. Also please note that I don't have any control over the JSON itself. It's generated by a third-party application to which I don't have access.

1 Answer 1

2

Got it figured out. Here's the process section of the config file for the multi-value link field:

process:
  field_department_link:
    plugin: sub_process
    source: department_data
    process:
      uri: department_url
      title: department_name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.