How to create a toggle button?

I am trying to create a button that changes a field from “IN” or “OUT”. So every time you click the button it switches it from one to the other. Click once and it changes it to “IN”. Click it again and it changes it to “OUT”. I can do two separate buttons where one button will change the status to “IN” and the other button changes it to “OUT”, but it would be nice to have one toggle button that can switch it.

Thanks

Hi Jennifer

You can use the If formula to specify what the next state of the field should be. Here is a document you can use to try the feature.

Himanshu

4 Likes

Thank you for replying. I clicked on the link you included, but it said I didn’t have access. I clicked on the request access button.

Sorry about that Jennifer. I have shared the document with you and also opened it up to everyone with an account in case others want to take a look.

That worked. Thank you so much!!

This is great Himanshu. Thanks. To save space, the ‘Occupied’ column could be hidden if you use a formula for the button label (=Occupied). In a perfect world, the button would be color controlled (green=on) too but color apparently applies to the entire column. Perhaps the developers could allow a formula for every button attribute (Color, Icon)?

2 Likes

Hi Himanshu,

I’d really like to look at the formula you used for this doc but it seems like the doc is corrupted now. I’ve been trying to copy an earlier version of it, but I can’t seem to be able to scroll down in the version history pane.

I tried the latest and the earliest version I was able to copy (Feb 16 2019, 8:57 AM), and whenever I click on the button column format, I get an error that closes the doc and asks me to reload it… :confused:

Dear @Andreea_Cri

You are right the doc is corrupted.
In the below link you can find a simular doc, to see how the formula works

Amicable,
//JP

Hi @Himanshu ,

It appears you made the document editable by everyone, and someone accidently messed up the formulas. I have created a new table with the correct formula.

I recommend you set the document to view/play and post an embedded copy so people can try it out and view the formula.

Cheers,
Lloyd

Hi Andreea

I have restored the document. Thanks for pointing out that the document was no longer working!

Thanks
Himanshu

Thanks for pointing this out Lloyd. I had shared this document last year and we didn’t support play mode back then. I forgot to go back and change the link after we implemented it. I have fixed the document and the link now.

No problem. For the record, I think a button that toggles between “ON” and “OFF” itself is sleeker, but perhaps not what was originally asked :wink:

Lloyd

A toggle button label is also possible. The label of the button can carry a formula itself. This would be an example formula:

SwitchIf(Column=“On”, “Switch off”, “Switch on”)

What this formula does is, when the column will show “On”, the button will read “Switch off”. If not that, then it will show “Switch on”.

(Edited my post to remove the reference for custom color fonts in buttons, because it could permanently crash your doc)