Converting Numbers to Words script does not work in automation

Hi all,
I am not a developer and I am trying to run a script that converts Numbers to Words each time a cell is updated… I found this script in a topic here, but I get this error when testing :

TypeError: output.markdown is not a function
** at main on line 1**

It is supposed by automation to convert in words when updated a cell called ‘Salarynumbers’ in another cell called ‘SalaryWords’ in a table named ‘Animateurs’

This is the script :

output.markdown('# Numbers to Words');

// establish the words arrays
let a = ['','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
let b = ['', '', 'twenty','thirty','forty','fifty', 'sixty','seventy','eighty','ninety'];

// get the name of the table
let table = base.getTable("Animateurs");

// get the records from this table
let result2 = await table.selectRecordsAsync();

// Update the records
for (let record of result2.records) {
    output.text(record.getCellValue("Salarynumbers") + " = " + inWords(a, b, record.getCellValue("Salarynumbers")));
    await table.updateRecordAsync(record, {
        // Change these names to fields in your base
        "SalaryWords": inWords(a, b, record.getCellValue("Salarynumbers")),

function inWords(a, b, num) {
    if ((num = num.toString()).length > 9) return 'overflow';
         var n = ('000000000' + num).substr(-9).match(/^(\d{2})(\d{2})(\d{2})(\d{1})(\d{2})$/);
    if (!n)
    var str = '';
    str += (n[1] != 0) ? (a[Number(n[1])] || b[n[1][0]] + ' ' + a[n[1][1]]) + 'crore ' : '';
    var hundredThousand = false;
    if (n[2] != 0) {
        str += (a[Number(n[2])] || b[n[2][0]] + ' ' + a[n[2][1]]) + 'hundred ';
        hundredThousand = true
    str += (n[3] != 0 || hundredThousand) ? (a[Number(n[3])] || b[n[3][0]] + ' ' + a[n[3][1]]) + 'thousand ' : '';
    str += (n[4] != 0) ? (a[Number(n[4])] || b[n[4][0]] + ' ' + a[n[4][1]]) + 'hundred ' : '';
    str += (n[5] != 0) ? ((str != '') ? 'and ' : '') + (a[Number(n[5])] || b[n[5][0]] + ' ' + a[n[5][1]]) + '' : '';
    return str;

Can someone help me to fix this please, and tell how to modify the script to make it run.

Many thanks

The output.markdown and output.text commands are not allowed in automation scripts. You can start by deleting all of those lines (or commenting them out).

Depending on the number of records in your table, you might also run into Airtable’s limits on the number of mutations per automation. The current script updates records one at a time. You may need to revise the script to update records in batches.

Hi kuovonne,
Thanks for your help.
I’ve deleted the lines but It probably exceeded airtable limits. I have many records on the table.
I’ve got this message :

I thought that the script will run only for the updated records one by one, but It seem like it runs for the whole records each time.
Can anybody help with a script running only for updated records with an automation.
Again I am not a developper and cannot arrange the script to make it work.

The script is designed to run for all the records in the table. If you want it to run on only the triggering record, it will need several lines changed. The changes are simple for someone familiar with JavaScript and the Scripting API, but complex to explain to someone new to coding.

Are you

  • interested in learning how to code yourself
  • interested in hiring someone who codes, or
  • hoping for a free script / free revision?

If you are interested in learning to code, this could be a good starter project. The find and replace example script shows how to update records in batches. If you want to change only the triggering record, you will need to learn how to adapt the script to work on a single record, and how to get that record from an input variable.

1 Like

Hi again kuovonne,
An again thank you for your answer.
To be honest, if the script revision is easy, it will be great if somebody could make the script changes / revision for free. If it is really a hard work, I can assess the possibility of hiring the services of a developer to do this.
I am unfortunately very busy to begin script learning, I would love to, but it needs time that I don’t have.