General Question about Pack Categories

Good Afternoon!

I have been reviewing the SDK for Packs. The pack options appear to be:

  1. Sync tables to get and push data to another SAAS via API - Combined with formulas.
  2. Formulas for the canvas.
  3. Actions for buttons and automations.
  4. New column formats in tables, using formulas.

I like the idea of incorporating a formula in a new column format type. However, I am stumped on the explanation for column formats. (See below). Is there example code available from start to finish for this type of pack? Also, what is the reason for using the “New RegExp”? Is there a good link to educate myself on this expression as it relates to CODA packs? Thank you, in advance.

Automatic formatting

When creating a new column, Coda tries to guess the type of the column based on the first data entered. Column formats from Packs can be included in this process by declaring matchers. Matchers are regular expressions that define which cell values the column format should be applied to. If one of the regular expressions matches the cell value the column format will be applied automatically.

pack.addColumnFormat({
  name: "Task",
  formulaName: "GetTask",
  // If the first values entered into a new column match these patterns then
  // this column format will be automatically applied.
  matchers: [
    new RegExp("^https://todoist.com/app/project/[0-9]+/task/([0-9]+)$"),
    new RegExp("^https://todoist.com/showTask\\?id=([0-9]+)"),
  ],
});

Column Format Description
Currently only URL patterns are fully supported, and the Pack must declare a corresponding network domain.

Only Packs already installed in the document will have their matchers used. If multiple column formats both match the cell input then Coda will choose one arbitrarily. If the user doesn’t want to use the column format they can manually change it afterwords.

2 Likes

HI @SIMG_ADMIN - Yes, we have a few column format samples in the documentation. Only the Todoist sample on that page uses automatic formatting using the matchers feature.

Automatic matching of column formats is an optional feature, and you don’t need to include any matchers. Each matcher is a rule that says “when the cell value matches, automatically apply this format”. Regular expression are a way to define a pattern, and are popular across many programming languages. They can be hard to write (and are even harder to read!) but tools like regex101.com can help you test them out.

3 Likes