How to use Format( ) with multiple Canvas templates?

I feel that must be a solution to my struggle with Format() formula and hope that the community can share experience.

My case:
Table1 with ColumnA - Name of a document, ColumnB - Canvas template. In the table there are for 20+ documents (contracts) each with it’s nicely prepared templates with 10+ { } variables each.

Table2 with 50+ columns which fill in the variables and ColumnA - “Selected Document” (reference to Table1) and ColumnB - “Filled in Template”. It’s expected that when a document is selected, it displays with the filled in fields. Later a button would copy this text and make it editable in another column “Editable Contract”.

The problem:
Every document has it’s own Format() formula to fill in the data. And I can’t figure out how to call the respective formula according to the Table3 “Selected Document” select list without creating a giant formula with Switchf().

I thought that I’ve achieved what I need with a third Helper table and using a Canvas column where to store the filled in data. But when I tried to copy the content from the Canvas column of Table 1 to a Canvas column in Table2 it removed all formatting of the text.

Below is a sample data:

1 Like

I’d love to help but I’m not sure I understand the problem.

Is it that the {1} {2} etc parameters are different for different sorts of contracts and therefore you cannot just use

Format(
  thisRow.DocType.Template,
  valueForParam1,
  valueForParam2,...
)

?

There’s a few ways. The first way is to just standardize your mapping of number to field, and in certain templates you can just omit certain numbers, i.e. making a contract template that reads, e.g., Item {23} is okay, too.

The second way is to move past named placeholders and implement named ones, e.g. I like the handlebars style like {{Name}}. There is a pack that can do it that’s free and by a Codan (@Eric_Koleda) — or if you need it more rapidly it can also be done locally but it requires a little formula stretching — actually this could be a topic for my tomorrow’s video because why not.

1 Like

Hi Paul, thank you for jumping in. You guessed it right. It’s because parameters are different for every contract and I was hoping to have a little simpler approach than using {1} and {99} in the same contract. I considered adding a number to the names of the columns. Or create a table where to map column name with number. If we could use names instead of numbers of Format() it would’ve been a lot easier. Now I will check the suggested pack to see if it makes it less complicated.

1 Like

Great suggestion, @Paul_Danyliuk–I think Handlebars is perfect for this. If this isn’t sufficient @Stefan_Stoyanov, let us know what you’re needing and we can maybe quickly build a pack.

2 Likes

Troy, I truly appreciate the offered help. For now, I might handle it all with the Handlebars pack seems to be a good fit.

But while you suggest a help with a pack, how about creating one which allows handwritten drawing in a cell? Quite ambitions maybe and a lot of times requested and many ideas in the community. This would make it all possible to work with signing documents directly in coda :slight_smile:

1 Like

In fact, there is a problem with this pack. It works only for super simple cases and only if every placeholder starts very differently. Even Name1 and Name2 “confuses” the pack and it renders errors.

So, still looking for ways to achieve this in a good sustainable way avoiding a 100+ list of variables with numbers.

If anyone know how I can copy an individual Canvas cell to an editable text cell, that might be enough to achieve what I need.

For now I’ve settled myself with the use of a table where I document the number and the respective formula.

Next challenge is to find out if there is a way to combine the Respective Formula column so that I can place it into Format([template],[list of Respective Formula]) and as such easily apply the changes from that list. Maybe there is a way to create a list of formulas from list of text? :upside_down_face:

Check out my Patreon :upside_down_face: I didn’t feel like making a regular video for the end of this week so I recorded you the (unedited) solution video there instead.

1 Like

Hey Paul, thank you for taking the time to look into this and offer this great solution! This is probably one of the most useful videos that I’ve seen in months related to Coda because it solved a real case which is beyond the “see how it works” demos. And most of all, it helped me see how you think about solving an issue, so this full unedited version is diamond for me.

With this solution the one thing we need to be careful with is to make sure that the names used as Tags use exactly the name of the column, otherwise it would not match it.

I hope you don’t mind me sharing my version of how I decided to approach it yesterday (before your solution). It’s a prove that I follow your Patreon videos very carefully :slight_smile: