Skip to main content
Solved

Copy and Paste from Date to Link fields UPDATE

  • November 11, 2021
  • 1 reply
  • 2 views

Hi! I saw an article that discuss my problem, but didn’t have the solution. I’m trying to create an automatization that runs a script to copy a field (formula that puts year and month together like this 2021-12) to a liked to field whenever a record is created ou updated.

So I found here this solution that requires you to put the field you want to copy as a primary field

let dateT = base.getTable('Dates');
let dateQ = await dateT.selectRecordsAsync();

for (let rec of dateQ.records) {
    let dateFieldID = rec.id
    await dateT.updateRecordAsync(rec, {
        'Date Link': [{id: dateFieldID}]
    })
}

But I can’t make this because I use my primary field to make a resume for my Calendar view title record. Here is a simple example how my table looks like

Does anyone solve this or could help me ?
(sorry if my English is not so clear. I’m an Brazilian who is trying his best here)

Best answer by Kamille_Parks11

A couple things:

  • Your script will update every single record one at a time, which is inefficient, regardless if those records changed
  • The script copies each record’s own ID into its link field, meaning it links records to themselves. This is not what you want: you are trying to link records to different records in another table
  • The script is not reliant on the date being the primary field. If you were to use a script, it would need to find records in Properties that have a matching date and find those record’s IDs.

It sounds like you just want to copy the {Source Date} field into the {Dates Link} field whenever the {Source Date} value changes. This doesn’t require a script.

Set your Automation trigger to be whenever a Properties record’s {Source Date} is updated. Then have an Update Record step set up like this:

View original
Did this topic help you find an answer to your question?

1 reply

Kamille_Parks11
Forum|alt.badge.img+15

A couple things:

  • Your script will update every single record one at a time, which is inefficient, regardless if those records changed
  • The script copies each record’s own ID into its link field, meaning it links records to themselves. This is not what you want: you are trying to link records to different records in another table
  • The script is not reliant on the date being the primary field. If you were to use a script, it would need to find records in Properties that have a matching date and find those record’s IDs.

It sounds like you just want to copy the {Source Date} field into the {Dates Link} field whenever the {Source Date} value changes. This doesn’t require a script.

Set your Automation trigger to be whenever a Properties record’s {Source Date} is updated. Then have an Update Record step set up like this:


Reply