Conditional Fields Plugin does not work with migrations

Hello,

After installing the aforementioned plugin either through migration or programatically through a script, we have faced an issue when n trying to update one of its field programatically.

The plugin contains two fields:

  • Fields to be show (which is a multiselect dropdown)
  • Invert (which is a boolean toggle)

The issue arises with the first field when using the api to update the value of targetFieldsApiKey through a migration of using content management api from a script, and the problem is that the updated value never shows in the UI select field.

Even when we are console logging the properties of the field, we can see that the array of targetFieldsApiKey contains our desired value.

Manually of course it works fine

Could you please help us out to figure out what is the issue :slight_smile: ?

const plugins = await client.plugins.all();

    const {id} = plugins.find((plugin) => plugin.name === "Conditional fields")

    const fieldIdOrApiKey = 'page::hide_navigation';

     await client.field.update(fieldIdOrApiKey, {
        appearance: {
            editor: 'boolean',
            parameters: {},
            addons: [
                {
                    id: id,
                    fieldExtension: "conditionalFields",
                    parameters: { invert: false, targetFieldsApiKey: ["banner_text"]  }
                }
            ]
        },
    });

Many thanks in advance :slight_smile:

We noticed that there is also an open github issue

Hello @technology

We replied to you over on the Github issue: ConditionalField plugin doesn't work with dato migration ยท Issue #58 ยท datocms/plugins ยท GitHub

1 Like

Thank you! We moved on without using the plugin due to other priorities, but hopefully, we can re-visit it when any use case of ours does require the conditional field plugin. :slight_smile:

The legacy datocms-client package is deprecated, and has issues when creating/updating plugins. Please use the new @datocms/cma-client-node, as it solves the issue!