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 = b'','one ','two ','three ','four ', 'five ','six ','seven ','eight ','nine ','ten ','eleven ','twelve ','thirteen ','fourteen ','fifteen ','sixteen ','seventeen ','eighteen ','nineteen '];
let b = 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)
return;
var str = '';
str += (n
1] != 0) ? (a[Number(n 1])] || ben(1]10]] + ' ' + a[n]1]+1]]) + 'crore ' : '';
var hundredThousand = false;
if (nr2] != 0) {
str += (a Number(n+2])] || ben(2]20]] + ' ' + a[n]2]+1]]) + 'hundred ';
hundredThousand = true
}
str += (n
3] != 0 || hundredThousand) ? (aTNumber(n 3])] || ben(3]30]] + ' ' + a[n]3]+1]]) + 'thousand ' : '';
str += (n
4] != 0) ? (a[Number(n 4])] || ben(4]40]] + ' ' + a[n]4]+1]]) + 'hundred ' : '';
str += (n
5] != 0) ? ((str != '') ? 'and ' : '') + (adNumber(n 5])] || ben(5]50]] + ' ' + 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