Help

The Community will be temporarily unavailable starting on Friday February 28. We’ll be back as soon as we can! To learn more, check out our Announcements blog post.

Copy and Paste from Date to Link fields UPDATE

Topic Labels: Automations
Solved
Jump to Solution
4787 1
cancel
Showing results for 
Search instead for 
Did you mean: 
Lucas_Pereira1
4 - Data Explorer
4 - Data Explorer

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
4a08c919e1e2ea8a73dbcfe739c09b550b1c50e0_2_525x316

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

59dfb6fd1ab6e46d1a09da1f7fdab2bd980f1340_2_525x213

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)

1 Solution

Accepted Solutions
Kamille_Parks
16 - Uranus
16 - Uranus

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:

image

See Solution in Thread

1 Reply 1
Kamille_Parks
16 - Uranus
16 - Uranus

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:

image