Skip to main content
Solved

Creating checkbox in rich text field via scripting


Martin_Malinda
Forum|alt.badge.img+10

Hello!

If I want to add a checkbox to a rich text field I simply type [] and checkbox appears.

But the same does not seems to work over scripting. I tried all kinds of combinations of `[] ` and `- [ ] ` and so on with no success.

```

let formattedInstructions = instructions.map(instruction => `- [ ] ${instruction}`).join('\n');
```

Maybe it's not possible right now?

Thank you!

Best answer by dilipborad

Hello @Martin_Malinda 
This has already been tested on my side.

👍

 

View original
Did this topic help you find an answer to your question?

5 replies

Saravanan_009
Forum|alt.badge.img+15

As of now, Airtable's rich text field does not support rendering checkboxes through scripting or Markdown-like syntax (e.g., [], - [ ]). The checkboxes that appear when typing directly into a rich text field are part of the WYSIWYG (What You See Is What You Get) editor functionality and aren't replicated when using scripts or formulas.


Martin_Malinda
Forum|alt.badge.img+10
  • Author
  • Known Participant
  • 15 replies
  • August 8, 2024

Thanks @Saravanan_009, good to have this confirmed. Seems like two different markdown implementations are at play here - one on the backend, another on the client. Good to keep this in mind.


dilipborad
Forum|alt.badge.img+20
  • Brainy
  • 217 replies
  • August 9, 2024

Hello @Martin_Malinda 
I've already implemented that. It works with a checklist.

Use automation script and then strictly follow spacing and format then it works perfectly fine.
See this specific example I've created for strings and arrays.

let inputConfig = input.config(); let recId = inputConfig.recId; // Uncomment this and fetch record using this and transform the data string //let table = base.getTable("Your Table Name"); //let record = await table.selectRecordAsync(recId); //console.log(record); let testmode = "string"; // Change this based on your mode let checklistArray = [{ value: "Check 1", "status": false }, { value: "Check 2", "status": false }, { value: "Check 3 Checked", "status": true }]; let checklistString = `[ ] Check 1\n[ ] Check 2\n[X] Check 3\n[ ] Check 4`; if (record) { let fields = []; if (testmode == "array") { checklistString = ""; for (let item of checklistArray) { if (!item.status) { checklistString += `[ ] ${item.value} \n`; } else { checklistString += `[X] ${item.value} \n`; } } } fields["Text CheckBoxes"] = checklistString // @ts-ignore let updateRecord = await table.updateRecordAsync(recId, fields); //console.log(updateRecord); }

I've also tested this it working fine for me.
Come up with your implementation if you still have issues.

👍


Martin_Malinda
Forum|alt.badge.img+10
  • Author
  • Known Participant
  • 15 replies
  • August 9, 2024

Ahh, this is good to hear, thanks @dilipborad! I tried different formats with no success, but I'll try your example and make sure the spacing is correct 🙏


dilipborad
Forum|alt.badge.img+20
  • Brainy
  • 217 replies
  • Answer
  • August 9, 2024

Hello @Martin_Malinda 
This has already been tested on my side.

👍

 


Reply