Help

Re: Button script to record todays date based on value of a single select field in corresponding date field

1988 1
cancel
Showing results for 
Search instead for 
Did you mean: 
matt_stewart1
7 - App Architect
7 - App Architect

I have a status column for the stage a project is in.

I tried using automation to record todays date when a stage is changed. However this is problematic as sometimes people select wrong stage for a split second and the system records that date. I explored having automation overwrite that date, but it still creates problems either route I go. So I would like to safeguard it by forcing user to click the button field next to the status field to confirm/submit.

So the idea is they select status they are starting today, and click the button. The script should then check the status field, and based on that value record todays date in the corresponding “actual date” field.

Is someone able to modify the below script to give a baseline of how/where I can enter the multiple status options it might find and the corresponding date fields to record to?

const config = input.config({
    title: "Timestamp with Button",
    description: "Use the associated Button field to fill Timestamp field with current DateTime.",
    items: [
        input.config.table('tableToUse', {
            label: 'Table to Use'
        }),
        input.config.field('timeStampField', {
            label: 'Field to fill with current DateTIme',
            parentTable: 'tableToUse'
        })
    ]
})

let record = await input.recordAsync('Record to timestamp', config.tableToUse)
let currentDateTime = new Date()
await config.tableToUse.updateRecordAsync(record, { [config.timeStampField.name]: currentDateTime })

3 Replies 3

It sounds like you have multiple date fields, and want to fill in a different date field, based on the value of the single-select field. However, the script that you have always sets the date in a single field.

The changes you want not difficult for an experienced coder, but it does involve adding significant changes to the code (mostly because there isn’t much code to begin with). The code would also need to be customized to your base.

I also suggest that since your users will need to click the button to set the date stamp, consider having the user select the stage in the script as well. Having a workflow where the user always starts by clicking the button makes it less likely that the user will forget to click the button. (And if people are selecting the wrong stage often enough for it to be a problem, they will forget to click the button.)

On the other hand, I think you might have given up on using automations to set the timestamp a little prematurely. If a record moves through stages in a straightforward pattern, it is possible to use automations without a script, even correcting for errors when people accidentally pick the wring stage and the stage needs to “go backward”.

Are you looking for

  • Help so that you can write the code yourself
  • Someone to write the code for you for free
  • Someone that you can hire to write the code you want
  • Advice on how to use an automation instead of a button script

If you are interested in writing the code yourself, please let us know your coding background, and share screen captures of your base.

If you are interested in hiring someone, there are several experienced script writers on these forums, including myself. If you are interested in hiring me, you can book a meeting with me.

@kuovonne yes correct, the workflow would be that they select status they are starting and then hit the record date button, this way its a 2 step process (compared to 1 step process via automation) but makes user really commit to that choice before recording a date / less chance for mistake recording.

I have novice level coding, so if I had a template I can usually start to piece it together and add in the additional fields or rename the fields etc.

regarding the automation route… thats a good point I didn’t think of… are you thinking its an additional action that says if a previous stage is selected then it removes the date too? or does this need to be a separate automation? I’ve got about 20-25 stages of tracking, which means 40-50 automations to setup/manage :frowning:

This doesn’t take into account the possibility of people forgetting to hit the button. Which case is more likely? People will pick the wrong stage or people will forget to hit the button? In either case, it sounds like you might need to invest more in user training.

I don’t know if such a template exists or not. I usually write my own scripts.

It sounds like an automation will not work for your situation, unless that automation has a script. Airtable has a limit of 25 named automations, and 25 action steps per named automation. You might be able to squeeze everything into automations given these limits, but I don’t advise it.