Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Mar 21, 2023 11:24 PM - edited Mar 21, 2023 11:27 PM
Hello everyone! I have created a new scripting extension which allows you to convert formatted text in your rich text fields into markdown!
The extension will look through all the records in the table you have selected and convert the selected field's text into markdown so that you can use it for your email, Slack, etc automations
Please feel free to reach out to me if you have any questions or feedback!
Installation instructions:
1. Click "Extension" at the top right
2. Click "Add Extension"
3. Click the "Scripting" extension
4. Click "Add Extension"
5. Paste the code below in!
let settings = input.config({
title: `Convert rich text field to markdown`,
items: [
input.config.table("table", { label: `Table` }),
input.config.field("richTextField", { parentTable: `table`, label: `Rich text field` }),
input.config.field("markdownField", { parentTable: `table`, label: `Output field` }),
],
});
let { table, richTextField, markdownField } = settings;
let query = await table.selectRecordsAsync()
let updates = new Array
query.records.forEach((record) => {
updates.push({
id: record.id,
fields:{
[markdownField.name]: record.getCellValue(richTextField.name)
}
})
});
while (updates.length > 0) {
await table.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}
Mar 22, 2023 07:15 AM
Looks like you are having fun writing scripts!
I noticed that your screen shot shows a single line text field for your output field. I recommend using a long text field without rich text formatting as the output field. Single line text fields are not designed to have multiple lines of text, which markdown often has.
Mar 23, 2023 12:39 AM
You are right! I have updated the base so that it uses a long text field for the output field now
Thank you 😀