Sync Table optional parameters appearing out of order

With a sync table that has multiple optional parameters, it seems the declared order of parameters is not respected when rendering the parameters in the configure menu in the Coda doc. The optional boolean parameters appear before the optional string parameter. Is this expected?

I believe the order is supposed to be honored. I tried to reproduce the behavior you mentioned, but I’m not seeing any reordering. Can you provide more information about when this happens?

Here is an MRE:

import * as coda from "@codahq/packs-sdk";

export const pack = coda.newPack();

pack.addDynamicSyncTable({
  name: "foo",
  
  listDynamicUrls: async function () {
    return [{
        display: "foo",
        value: "foo",
      }];
  },
  getName: async function () {
    return "Foo";
  },
  getDisplayUrl: async function (context) {
    return context.sync!.dynamicUrl!;
  },
  getSchema: async function (context) {
    return coda.makeObjectSchema({
      properties: {
        name: {
          type: coda.ValueType.String,
          description: "The name."
        },
      },
      idPropert: "name",
      displayProperty: "name",
      featuredProperties: ["name"],
    });
  },
  identityName: "afoo",
  formula: {
    name: "Foo",
    description: "",
    parameters: [
      coda.makeParameter({
        type: coda.ParameterType.String,
        name: "nonOptString",
        description: "",
      }),
      coda.makeParameter({
        type: coda.ParameterType.String,
        name: "optString",
        description: "",
        optional: true,
      }),
      coda.makeParameter({
        type: coda.ParameterType.Boolean,
        name: "optBoolean",
        description: "",
        optional: true,
        suggestedValue: false
      })],
      execute: async function (params, context) {
        return { result: [] };
      }
    }
});

I am quite unsure why this happens, but I am guessing it is due to the combination of parameters.

Thanks for sending that along! It seems like the issue is related to the suggestedValue on that parameter. If you remove it, then they show in the expected order. I’ll raise this with the team and see if I can get more information.

2 Likes

It seems the underlying issue here is that optional sync table parameters are currently being moved to the top if they have a value assigned. Setting a suggestedValue on the parameter means that it has a value from the start, hence moves to the top. It’s unclear if this reordering is intentional or not, but I’ll follow up with the team to learn more.