When you’re filling out bank forms, the bank documents usually require their customers spell out the amount they put in into words. This is one way for banks to make sure customers really meant the number they put in their forms, and not made a typo. This poses a problem when you’re using Airtable’s Page Designer to auto-populate the bank forms from your Airtable records. Yes, you can type it out in a separate text field, but there must be a way to automate this, right?

Let’s say, you have a field called “Amount Sold” in your base. Go to Automations, and in one of your actions, select Run Script. Add an Input Variable and name it amount_sold , then for the Value select the “Amount Sold” field from your base.

Input Variable in Airtable

Input Variable in Airtable

Now paste the following in the Code area:

let inputValues = input.config();
let amount_sold = inputValues.amount_sold;

var dg_val = ['Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'];
var tn_val = ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'];
var tw_val = ['Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'];
var th_val = ['', 'Thousand', 'Million', 'Billion', 'Trillion'];

function toWordsconver(s) {
  s = s.toString();
  s = s.replace(/[\, ]/g, '');
  if (s != parseFloat(s)) {
    return 'not a number';
  }
  var x_val = s.indexOf('.');
  if (x_val == -1) {
    x_val = s.length;
  }
  if (x_val > 15) {
    return 'too big';
  }
  var n_val = s.split('');
  var str_val = '';
  var sk_val = 0;
  var decimal_str = '';
  for (var i = 0; i < x_val; i++) {
    if ((x_val - i) % 3 == 2) {
      if (n_val[i] == '1') {
        str_val += tn_val[Number(n_val[i + 1])] + ' ';
        i++;
        sk_val = 1;
      } else if (n_val[i] != 0) {
        str_val += tw_val[n_val[i] - 2] + ' ';
        sk_val = 1;
      }
    } else if (n_val[i] != 0) {
      str_val += dg_val[n_val[i]] + ' ';
      if ((x_val - i) % 3 == 0) {
        str_val += 'Hundred ';
      }
      sk_val = 1;
    }
    if ((x_val - i) % 3 == 1) {
      if (sk_val) {
        str_val += th_val[(x_val - i - 1) / 3] + ' ';
      }
      sk_val = 0;
    }
  }
  if (x_val != s.length) {
    var y_val = s.length;
    decimal_str = 'and ' + n_val.slice(x_val + 1).join('') + '/' + Math.pow(10, y_val - x_val - 1);
  }
  return str_val.replace(/\s+/g, ' ').trim() + ' ' + decimal_str;
}


output.set("amount_sold_in_words", toWordsconver(amount_sold));

If you run this script, you’ll get an output called amount_sold_in_words, which you can then use in your next action. If you have a number like 15,230,150.25 in your “Amount Sold” field, this will return “Fifteen Million Two Hundred Thirty Thousand One Hundred Fifty and 25/100”, which using Automation you can input into another field of the same record.