Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Formula to generate icons when box is checked

Solved
Jump to Solution
133 4
cancel
Showing results for 
Search instead for 
Did you mean: 

I'm pretty sure I've seen this covered before, so forgive the reposting. 
I want to create a field that generates a flag icon/emoji if a checkbox field is checked.

I'll use this to add the icon to my field title (using Concatenate) so it draws attention. I've done the same thing using the SWITCH formula, but I can't figure out how to do it with a checkbox field.

TIA! 

1 Solution

Accepted Solutions

(I'm on the freeplan so can't run a script based on a field change).

@John1  Note that .updateNameAsync() only works in scripting extension, not automations scripts, so this particular script won't work in an automation anyway.

@Joel_Andrews1 
Since you refer to being able to do this with a SWITCH() formula, I'm guessing that you want a formula that will give you an emoji that you can use in the value of the primary field of the record, versus changing the actual field name.
Try something like this ...

IF( {checkbox field name}, "🤖")


Be sure to put the emoji in straight quotes.

See Solution in Thread

4 Replies 4

Hey Joel
Here's a start for you - I made this script run on a button field next to the checkbox field (I'm on the freeplan so can't run a script based on a field change).
Change the YOURFIELDID to the ID of the checkbox field an YOURFIELDNAME to the name of the checkbox.
You'll also want to change the "TRUE" and "FALSE" to the icon you want to use.
It's just a start as I believe when you remove the icon from the field name you'll have to check ALL records to see if any other checkbox is set to True and if it is then you want the icon to stay put.


----------------------

const tableId = cursor.activeTableId;
const table = base.getTable(tableId);

let record = await input.recordAsync('Pick a record', table);

// if we have a record
if (record) {

// change the checkbox to either on or off
table.updateRecordAsync(record, {"YOURFIELDID" : ! record.getCellValue("YOURFIELDID") });

// get the field
let field = table.getField("YOURFIELDID");

if(record.getCellValue("YOURFIELDID") == null) 
  { 
    myvalue = "TRUE"
  } 
else 
  {
   myvalue = "FALSE"
  } ;

await field.updateNameAsync(("YOURFIELDNAME " + myvalue));

}

(I'm on the freeplan so can't run a script based on a field change).

@John1  Note that .updateNameAsync() only works in scripting extension, not automations scripts, so this particular script won't work in an automation anyway.

@Joel_Andrews1 
Since you refer to being able to do this with a SWITCH() formula, I'm guessing that you want a formula that will give you an emoji that you can use in the value of the primary field of the record, versus changing the actual field name.
Try something like this ...

IF( {checkbox field name}, "🤖")


Be sure to put the emoji in straight quotes.

Looks like the forum software doesn't like emoji. It turned my emoji into text.

That's exactly what I was looking for. Thanks!