Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

Increase number

Topic Labels: Scripting extentions
Solved
Jump to Solution
1344 5
cancel
Showing results for 
Search instead for 
Did you mean: 

Hi

I wanna script a (+1) button, somehow (like) button… to increase (or decrease) number in a filed

For example, When I click this button, the filed X become (10) instead of (9)

Thanks

1 Solution

Accepted Solutions

Happy Holidays

const config = input.config({
    title: 'Add 1 to a number field',
    description: 'A script that lets you increment a number',
    items: [
        input.config.table('table', {
            label: 'Table',
        }),
        input.config.field('numberField', {
            label: 'Number field',
            parentTable: 'table',
        }),
    ]
});

const record = await input.recordAsync("Pick a record", config.table)
const currentNumber = record.getCellValue(config.numberField)
const newNumber = currentNumber ? currentNumber + 1 : 1
await config.table.updateRecordAsync(record, {
    [config.numberField.name]: newNumber 
})
output.markdown(`Updated ${config.numberField.name} for ${record.name} to ${newNumber}`)

See Solution in Thread

5 Replies 5

Welcome to the Airtable community!

Do you want to hire someone to write this script for you?
Are you hoping that someone will write this script for you for free?
Are you trying to write a script and need help debugging it?

Yes I can hire someone, I just not sure if that possible.
I know little about coding

Yes, this is quite possible with a script. Several people in this community (myself included) write scripts for hire.

Happy Holidays

const config = input.config({
    title: 'Add 1 to a number field',
    description: 'A script that lets you increment a number',
    items: [
        input.config.table('table', {
            label: 'Table',
        }),
        input.config.field('numberField', {
            label: 'Number field',
            parentTable: 'table',
        }),
    ]
});

const record = await input.recordAsync("Pick a record", config.table)
const currentNumber = record.getCellValue(config.numberField)
const newNumber = currentNumber ? currentNumber + 1 : 1
await config.table.updateRecordAsync(record, {
    [config.numberField.name]: newNumber 
})
output.markdown(`Updated ${config.numberField.name} for ${record.name} to ${newNumber}`)

Happy Holidays!

This Worked great…

Thank you!