Control Checkboxxes in Textfield

In textfields we have the option to create a checkbox list,
Can we control (check/uncheck) the checkboxxes also through a formula?

Of course I can create a couple of seperate checkboxxes, but by using this option, this will give me a much more compact view of tasks which have to be done before (in my case) an invoice is ready to be send.

I did some more research, I wonder if i’m on the right way if I try to solve this problem by altering the raw data, and add the ‘isChecked’ with a formula. Afterwards I have to render the JSON again back to the list of checkboxxes of course, which seems to be a challenge aswell.

Recording 2022-08-10 at 16.29.19

I think @Paul_Danyliuk already had a solution for this, but I wasn’t able to find it via search right now, maybe he can jump in? He is defenitely the right guy :slight_smile:

Perhaps this is the approach:

IIRC now you can easily split by newline, apply paragraph style formatting, and merge back.

4 Likes

Thanks! Going to experiment!

Wow, just got reminded from @Christiaan_Huizer and @Paul_Danyliuk that I even made the example some time ago for that problem :smiley: Still all props to Paul for teaching black magic :wink:

It only shows the “Uncheck” part, but you can do exactly the same with a _checked column and make a “check all” button out of it.

Here the example again:

2 Likes

@Daniel_Stieber Thanks for you help, I had some trouble as it seems Coda changed some things in the way the JSON code of the TextField-Checkboxxes work. For example, in the current JSON code there is no ’ isChecked: False’ (see also the GiIF in the post of yesterday) so the RegexReplace does not work if the checkbox is initially unchecked.

Also the Split/Join option as @Paul_Danyliuk mentioned seems not to work anymore, when splitting a checkbox list, the checkbox is not removed. And also joining with an empty checkbox seems not to be adding one (at least not in the demo in my enviroment).

Another issue for me is the fact I don’t want a list to be checked or cleared completely, I want to check a certain box (when a step is finished in another table).

So now I created a column (isChecked) with a new object:

object(“root”,object(“children”,array(object(“isChecked”,thisRow.Status))))
where Status is a good-old formula-controlable checkbox.

Which I’m merging (and parsing) with the orginal Textbox into a new Column:
ParseJSON(‘{“o”:’+ thisRow.Task._merge(thisRow.isChecked)+‘}’)

Finally I can concatenate the different TaskStatuses into a new column.
I takes quite some helper columns (I guess some can be eliminated?)

As I’m quite new into the coda community, I guess my solution is probably not best-practice (and relying on experimental functions), but for now it wil do the job.

@Ronald_van_Meurs Yeah that sounds veery complex to build and maintain.
Maybe its easier to just go a different path.

As I undestand you want:

  • A checklist of things to do.
  • Buttons that check todos on the list.

You could just make a checklist column per todo and then have a button or multiple buttons to set these to true (more about using one button column to do different things here)

Then make a list with concat where you show your checklist and use emojis instead of the coda checkbox.

You can’t click on your “Concat” column in your last example anyway, so this would be the same result, just little different look.

This way you don’t need any json manipulation and only one column per checkbox / todo.

Would that suit your scenario?

2 Likes

Here as an example. I know its not exactly it, because the PDF column is not a textfield. But maybe it makes sense to refactor it in such a way anyway to not rely on hacking around with JSON

If you explain the full use case, maybe there is a different simple solution as well.

2 Likes

Okay, this works out perfectly… the result looks even better :grinning:

I learned a lot from creating my solution, but it’s way too complicated, especially compared to yours.
I was barking up the wrong tree.

Thanks again!

2 Likes

That something that I found surprising as well. It had been my assumption that the formula:
thisrow.Ingredients._Merge().ToText())

would result in the JSON, which for each item within that list would indicate either “isChecked”:True or “isChecked”:False.

As you state, though, @Ronald_van_Meurs , I also found that this parameter is not present for unchecked checkbox items, but solely is added when the checkbox is ticked-off (hence, when it is changed to “isChecked”:True.

That rendered my intent to formulaically control the checkboxes via a formula
thisRow.Raw Json.regexreplace('"isChecked":true','"isChecked":false' )
moot.

I dabbled around some more trying to Concatenate the parameter isChecked to each item within that list, but it soon became obvious that this not a sustainable method.

So, I too think that Buttons are the way to go, instead of diving ever deeper into ParseJson :wink:

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.