Dynamic Schemas in SyncTable

Hi All,

I am creating a coda pack where I have one syncTable. Based on the parameter, I need to call different API’s and I need to return different schema object values. I am trying to add the schema inside the formula based on the parameter. But I am getting compiled time error as the syntax is not correct. Can you please guide me how can I achieve that ?

pack.addSyncTable({
  name: "Users",
  //schema: UserSchema,
  //identityName: "UserIdentity",
  formula: {
    name: "SyncUsers",
    description: "Sync Users Table",
    parameters: [coda.makeParameter({
      type: coda.ParameterType.String,
      name: "docName",
      description: "Name of the document",
      optional: false,
    })
    ],
    resultType : coda.ValueType.Array,
    schema : UserSchema,
    isAction: true,
    execute: async function ([docName], context) {
   return ""
}

Thanks,
Elam

Hi @Elam_Jaybal - Great to hear you are building a Pack! A few comments:

Based on the parameter, I need to call different API’s…

Just so you are aware, by default Packs are only allowed to make requests to a single domain. If your APIs are on different domains you’ll need to request an exemption.

and I need to return different schema object values

A sync table must define it’s schema, and that schema itself can’t change based on the parameters. Your best solution is probably define a schema which contains the fields from either API.

But I am getting compiled time error as the syntax is not correct.

Your code seems to be a mix of a sync table and a button, using parts from each. I’d recommend taking a deeper look at the sync table samples (and template) to get a sense for the structure.