Changes to blank values in two-way sync select lists

In short: Pack makers that have built Packs using two-way sync with select lists may need to update their code.

The hint type SelectList was added to the Packs SDK to allow for synced columns to be edited like select lists. The Pack code defines which values are allowed for the select, using either a static array of options or a function that dynamically fetches them.

image.png

Currently these select lists only contained the defined options, but normal Coda select lists also include a “Blank” option, which is useful when you want to remove or unset the value.

image.png

Starting on January 22, 2024 we’ll be changing the default behavior of two-way sync select lists to also include the blank option. If you wish to remove the blank option for a given column, update your Pack to set the property field requireForUpdates to true.

const ExpenseSchema = coda.makeObjectSchema({
  properties: {
    // ...
    category: { 
      type: coda.ValueType.String,
      codaType: coda.ValueHintType.SelectList,
      options: async function (context) {
        return await getCategories(context);
      },
      // A category is required, so don't offer the "Blank" option.
      requireForUpdates: true,
    }
  }
});

Be aware that even with the blank option removed there are other ways for a user to clear the value of the cell, for example using the delete key or the “cut” keyboard shortcut. So you may still want to include some validation in your Pack code to make sure a value is set.

Finally, this change also applies to Relation columns (created using the Reference hint) that define an options function. You can likewise use requireForUpdates in those properties to disable the blank value.

4 Likes

The SDK throws an error when trying to upload the changes, although I am using the latest SDK version. Any help is appreciated.

Thanks for reporting that @packwhale. I tried to reproduce the issue, but I couldn’t get the same error. Here’s what my property looks like:

    priority: {
      description: "The priority of the task.",
      type: coda.ValueType.String,
      codaType: coda.ValueHintType.SelectList,
      options: [
        {display: "P1", value: "4"},
        {display: "P2", value: "3"},
        {display: "P3", value: "2"},
        {display: "P4", value: "1"},
      ],
      mutable: true,
      requireForUpdates: true,
    },

It seems almost identical to yours, and I’m also using SDK version 1.7.4, so I’m sort of stumped as to why yours is failing.

If you create a new Pack with a really simple schema does it still repro for you?

1 Like

Solved, I have removed the package.json and the node_modules folder and installed all packages again. Thanks :ok_hand:

2 Likes