Drupal Field Content Migration with Views Bulk Edit module

Zaid Al-Dabbagh
4 min readJun 8, 2023

--

Use the Views Bulk Edit module to migrate content for individual fields on selected content types. This is made possible with use of Drupal’s Views Bulk Edit module, which allows us to setup new Views for the purpose of migrating fields.

Photo by CHUTTERSNAP on Unsplash

Prerequisites

  • Label source fields “(Old)”
    Before starting, mark legacy source field labels with an indicator so it’s more obvious which fields are old. E.g. Navigate to source field settings and change label from “Some Field” to “Some Field (Old)”.
Marking old field labels with “(Old)” makes it easier to identify in Drupal CMS.

Step 1 — Setup new destination fields

  • Create destination fields
    Create new destination fields to which source field values will be migrated to. In this example, we will be migrating the content of the field_status list field to the newly setup taxonomy term list field_status_taxonomy.
Source and destination fields in Drupal CMS.

Step 2 — Setup a new View with the Views Bulk Edit module

  • Select option to “Create a page” in Page settings.
  • Save and edit.

Step 3 — Update View configs

  • Set Format option to use HTML List.
  • Set Show to Fields
  • Add a “Views bulk operations” field (global) … And Select “Modify field values”
  • Now add both the source field (`field_status`) and the destination field (`field_status_taxonomy`), and remember to add a label too which will display in the list.
  • Add Content Type in Fields options, so that this is exposed in the list.
  • Re-arrange fields into logical order: Title, Content Type, Source Field, Destination Field, etc.
  • This is what Fields should look like:
  • Configure Filter criteria
  • Remove “Content: Published (=Yes)” rule, as we want the migration to apply to all nodes.
  • Add Content Type, then filter to relevant content types, so only those are impacted.
  • Add old field (In this case “Status (Old)” as a filter — We will expose this too.
  • Set Pager to Display All Items
  • Change Access to Admin Role

Step 4 — Running the Field Migration

Load View by path (https://drupal.local/migrate-achievement-standard-status)

Then apply

  • Select destination field to change.
  • Then map the source / destination values.
  • Repeat for each option.

Step 5 — Delete Legacy Source Fields

Now that content has been migrated, it’s time to delete the source fields.

  • Ensure all fields to be removed are marked not required in field settings.
  • Go to each field and delete the field in the CMS.

Search through code and unwire any references to the old fields.
Caution: make sure you search the following:

  • Twig template code.
  • YAML configs.
  • Custom module and theme preprocess code.

References

--

--

Zaid Al-Dabbagh

UI/UX Designer. Founder of @pandauxstudio . Speaker at @UXNewZealand . Family Guy & Father of 3. Coffee Lover. Arabic Calligrapher. Iraqi-Born Kiwi.