Help

Re: Button that runs a script to generate a random string

942 0
cancel
Showing results for 
Search instead for 
Did you mean: 
noelng
4 - Data Explorer
4 - Data Explorer

I'm not familiar with Javascript.

Looking to make a button that will start a script to generate an alphanumeric string that's 8 characters long.  

The code I found on Google to generate a string is:

function makeid(length) {
    var result           = '';
    var characters       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
    var charactersLength = characters.length;
    for ( var i = 0; i < length; i++ ) {
        result += characters.charAt(Math.floor(Math.random() * charactersLength));
    }
    return result;
}

console.log(makeid(8));

However, I'm not sure how to make it output into a record in a table in Airtable.  Is it possible to make it replace the same record every time the button is pressed?  Is it possible to clear the record after x amount of time?

 

1 Reply 1

Yeah sure, here:

Screen Recording 2023-01-25 at 4.05.32 PM.gif

Base link

> Is it possible to clear the record after x amount of time?
Yeah, create a "Last modified time" field that looks at the field with the random string, create a formula field that will check whether it's X amount of time since it was last updated, and get an automation to trigger off that and clear the value