Need help with Buttons

Hello Coda community.

I have a doc that has implemented the time track feature of this template.

I’ve managed to implement that very well by copying the codes and implementing at my doc and it actually works. However now after some time I’m running into an issue

Well, if you access the template, you’ll see that if you click the tab Today and click on any Clock in button, it’ll turn gray and the Stop button will turn red; then it starts to log the time in the timesheet table. If you click Stop, then it finishes this record. It is working exact like this in my doc, except that when I click on Clock in all the buttons in all the rows turn gray and all the other Stop buttons turn red; it behaves like it is loging the time to all rows, but it is not; the problem with this is that, if I click a button and all the others turn gray, I cannot do that on another row to work on two or more things at the same time.

The original doc (the template) lets you click one, two, three… x buttons and they work separately. Mine does not. What might I be doing wrong?

Hey @Tiago_Melo for this type of thing its really helpful if you can share an ‘anonymized’ version of the doc, or a screen recording so we can see the details. Computer code functioning properly can be as subtle as a comma, in the wrong place.

Hi @Tiago_Melo,

There are a couple things in the button settings that might make this happen. The first thing to check are the fields that tell the button which rows to act on. Button actions can apply to all rows, or only the rows that match a custom filter, or just “thisRow()” which is the current row the button is in. For this template, it looks like it’s a custom filter to single out the rows.

The other field to check is the “Disable” field. This tells the button when to be disabled.

Thanks BenLee, but the code seems exact the same to me and it has “thisrow()” there, plus it also has a condition in which only started tasks display a field and it is used on Disable field (just like the original code)

Agreed, it is better with the link for an anonymized version indeed.
This is my doc (I had to exclude several rows in several tables, but everything is here (including the issue))

You can ignore (at least at first) a lot of tabs in the sections. You’ll see that there are a lots of views for tasks, but the easier one to see the code and reproduce the error will be a tab called Tasks under the section Tasks (sorry for the redundancy). If you drag the horizontal slider to see the columns that are out of the screen, eventually you’ll get to some columns with 3 buttons: Duplicate Task, Start and Stop. You can ignore Duplicate Task (it works correctly and it is not a problem) and check how Start and Stop buttons are working; I left 3 tasks here and if you click Start in one of them, all of them start counting, and if I click any of the Stop buttons, all of them stop.
Curiously, the time that gets logged to the Timesheet table (under the section Time logs data), is correct; it is logging only the time for the correct task (the linking field is the column Index in Tasks table). However, the fact that all buttons behave like this means that I cannot start 2 or more tasks at once and that’s what is really annoying me (some times we all multitask, that’s life… haha… ha…); and last, but not least, if you compare my doc with the original one (in which my doc was based on), you’ll see that the original works like I intend mine to work.

Thanks for the help in advance (it is probably just some easy detail that I’m missing here).

Best regards,
Tiago Melo

Hi @Tiago_Melo,

For the column “Current Event”, delete what you have and try this:

Timesheet.Filter([Task Index]=thisRow AND Running)

The current formula is picking up the same value for every row, so all the buttons are active. This will compare the index for the current row against the other table, so only the relevant button will be enabled.

Hello BenLee.
By "Current Event, I’m thinking that you perhaps are referring to the column Current Entry on table Tasks, because the code is similar and also the name is similar (plus I do not have a column Current Entry.

If I do that (and I did for testing), the buttons simply do not work anymore (they turn out gray and unclickable with error message If expects parameter condition to be a value, but found value (’’), which is a table. Open column format to fix.

And, in any case, this is not the error, because on the original sheet (The Timesheet template) in which this feature is working the code is exactly the same as at my sheet.

Sorry, there are a couple other things to change to get this to work.

Yes, Current Entry is the one I meant. Also, make this column format “Text” instead of a lookup.

For the Start button, in the disable field, use this formula instead:
thisRow.[Current Entry].Count() > 0

That template is an older one and there have been a few changes that affect formulas since then.

Actually, I was brainstorming about each aspect of it and I nailed it!
I’ll explain in a reply to myself, ha!

I’ve made some changes that nailed down the task of making this really work as I intended!
Check the doc here

First, I must thank BenLee, as he pointed out the column Current Entry and that was one of the keys.
The way the filter was being applied was not being sufficient to evaluate rows that had running column as true and that had the task index = to the indexes in Tasks table. I’ve changed the code and now it was being populated. This action was enabling the correct Stop button and disabling the correct Start button, as now this filter is working.

Second, I was having an issue with the button Stop now… it was not working anymore because the filter was also incorrect. A simple change to the filter in this button’s formula dealt with it and now evetything works as I intended at first!

Thank you all for the tips. I’ll leave it as it is now… haha

1 Like

Ah, this would work as well but only if I was able to fix Current Entry (as you first pointed out)… anyway, it is fixed now :slight_smile: