2

I'm trying to run a migration and one of the fields in Drupal is a boolean. For some reason I cannot get it to import the boolean value.

In Drupal

The field type is boolean, the on/off labels are yes/no (I've also tried setting them to on/off). the machine name is field_release_compilation

In my data source (Google sheets the data is stored as:

"gsx$compilation":{"$t":"1"}

I have also tried values of "TRUE", "on", "Yes" as well as "1"

In my migration

I'm using the google sheets plugin, along with migrate plus and migrate tools. The rest of the data pulls in fine so there's no issue connecting to sheets or that it's viewing the wrong doc/worksheet.

I remap the field using (I'm remapping every field, the others work fine)

fields:
- name: Compilation
  label: Compilation
  selector: compilation

I've tried the following ways of processing the field, all to no avail:

field_release_compilation:
  - type: bool
    source: Compilation

field_release_compilation:
  - fieldtype: bool
    source: Compilation

field_release_compilation:
  - type: boolean
    source: Compilation

field_release_compilation:
  - fieldtype: boolean
    source: Compilation

field_release_compilation:
  - callable: boolval
    source: Compilation

I'm not sure what to try next...

3
  • 1
    Have you tried field_release_compilation: Compilation?
    – sonfd
    Commented Jun 5, 2020 at 1:00
  • 3
    Also, I think you want to use 0/1 as vals in your google sheet unless you're planning to use a process plugin to manipulate.
    – sonfd
    Commented Jun 5, 2020 at 15:43
  • 1
    Hi, Yes I've tried both of those. Neither works
    – Al_
    Commented Jun 9, 2020 at 20:08

1 Answer 1

0

The convert_boolean process plugin is a good option https://git.drupalcode.org/project/migration_tools/-/blob/8.x-2.x/src/Plugin/migrate/process/ConvertBoolean.php

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.