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.