Help

Re: Increase number

Solved
Jump to Solution
1616 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Badr
5 - Automation Enthusiast
5 - Automation Enthusiast

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

2 Solutions

Accepted Solutions
kuovonne
18 - Pluto
18 - Pluto

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

Badr
5 - Automation Enthusiast
5 - Automation Enthusiast

Happy Holidays!

This Worked great…

Thank you!

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?

Badr
5 - Automation Enthusiast
5 - Automation Enthusiast

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.

kuovonne
18 - Pluto
18 - Pluto

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}`)
Badr
5 - Automation Enthusiast
5 - Automation Enthusiast

Happy Holidays!

This Worked great…

Thank you!