Help

Re: My spellchecking script isn't working

1130 1
cancel
Showing results for 
Search instead for 
Did you mean: 
JonathanB
8 - Airtable Astronomer
8 - Airtable Astronomer

Hi everyone.  I'm not a coder so have been relying on ChatGPT to help me with scripts.  It gave me this one for a spellchecker that looks in a field for misspellings of the word "epilepsy".  I have checked the name of the field and of the table are correct and filled in accordingly, but when I run the script, nothing happens.  No error message, it just runs and the console remains empty.  Any ideas what's going on?  Here is my script:

 

 

 

 

// Define the table and field you want to check
var tableName = "YourTableName"; // Replace with your actual table name
var fieldName = "YourFieldName"; // Replace with your actual field name

// List of common misspellings
var misspellings = ["epilepsey", "epilipsy", "epilepcy", "epilepsy", 
                    "eppilepsy", "epillepsy", "epilepsy", "epliepsy", 
                    "epilespy", "epilepsie"];

// Function to search for misspellings
async function findMisspellings() {
    var table = base.getTable(tableName);
    var query = await table.selectRecordsAsync();
    var foundMisspelling = false;

    console.log(`Checking records in ${tableName} for misspellings in ${fieldName}...`);

    query.records.forEach(record => {
        var text = record.getCellValueAsString(fieldName);
        if (text) {
            misspellings.forEach(misspell => {
                if (text.toLowerCase().includes(misspell)) {
                    console.log(`Misspelling found in record ${record.id}: ${misspell}`);
                    foundMisspelling = true;
                }
            });
        }
    });

    if (!foundMisspelling) {

 

 

 

 

3 Replies 3

Sorry, I don’t know scripting, so someone else will need to help you there. But if you want to do this in a no-code way that doesn’t require any scripting or coding at all, you can always integrate the Bing Spell Check by using Make. If you’ve never used Make before, there’s a bit of a learning curve, so I give some good training tips in this thread

Sho
11 - Venus
11 - Venus

Hi @JonathanB
This code does not appear to have completed all of its generation.

Even if a function is defined, if it is not executed, nothing is output.

// Define the table and field you want to check
var tableName = "YourTableName"; // Replace with your actual table name
var fieldName = "YourFieldName"; // Replace with your actual field name

// List of common misspellings
var misspellings = ["epilepsey", "epilipsy", "epilepcy", "epilepsy", 
                    "eppilepsy", "epillepsy", "epilepsy", "epliepsy", 
                    "epilespy", "epilepsie"];

// Function to search for misspellings
async function findMisspellings() {
    var table = base.getTable(tableName);
    var query = await table.selectRecordsAsync();
    var foundMisspelling = false;

    console.log(`Checking records in ${tableName} for misspellings in ${fieldName}...`);

    query.records.forEach(record => {
        var text = record.getCellValueAsString(fieldName);
        if (text) {
            misspellings.forEach(misspell => {
                if (text.toLowerCase().includes(misspell)) {
                    console.log(`Misspelling found in record ${record.id}: ${misspell}`);
                    foundMisspelling = true;
                }
            });
        }
    });

    if (!foundMisspelling) {
        console.log(`No misspellings found in ${fieldName} field in records of ${tableName}.`);
    }
}

// Call the function to start the search
findMisspellings();

 

JonathanB
8 - Airtable Astronomer
8 - Airtable Astronomer

What would I need to add to it to give an output? @Sho