Re: Duplicate record - clear fields/move values in fields

1504 0
Showing results for 
Search instead for 
Did you mean: 
6 - Interface Innovator
6 - Interface Innovator

I posted a related question a couple of weeks ago, and was able to implement the Script Block (Add new (semi-duplicate) record when checkbox selected) - super awesome, and THANK YOU!

Here is what i need to do next:

Field Names
Current Item Title
Current Item Desc
Curr Editor Item Title Direction
Curr Editor Item Desc Direction
Curr Editor Item Title Modified
Curr Editor Item Desc Modified
Curr Edits Complete (checkmark box)
Curr Edits Implemented (checkmark box)

Each item is updated monthly. I need to copy the existing record to a NEW record, over writing the CURRENT TITLE/DESC with the MODIFIED TITLE/DESC, while also clearing out the “direction” fields, “modified” fields and the “Complete” & “Implemented” checkmark boxes.

The script from the last solution creates a duplicate record, but doesn’t move/clear out certain fields.

What’s the easiest way to implement something like this. I’m managing hundreds of items a month, and do it manually is both time consuming and leaves so much room for human error…

6 Replies 6

Does this need to be an update to the script from the original thread, or a new script? If it’s an update, could you share the script you currently use? It was likely modified from what @Kamille_Parks originally wrote, so it’s best to work with that vs her original.

Do you mean leaving those fields empty in the new record, or removing those values from the original record?

@Kamille_Parks original script worked in a base that we’re using to “test” scripting. I’m attaching an image of what I need to ACTUALLY when the record duplicates. Ideally, the update would be triggered when I select “Client Implement Complete” with a CHECK.

The “original” record will not be modified in any way in the process - I will only indicate that the client has implemented the content (which should also be cleared in the duplicate record).

See a live example of what I’d like to be automated (first record is the ORIGINAL record, second record is what I would like to be the final output).

Record Duplication Example

Modified script:

let table = base.getTable("Insert Name of Table Here")
let query = await table.selectRecordsAsync()
let records = query.records

// Add a new object to the ${replacements} array for each pair of fields where values are to be switched 
// Values from the "copiedFrom" field will be copied in the new record to the "copiedTo" field
// If values should be copied to the same field, you only need to identify the "copiedFrom" field
let replacements = [
        copiedFrom: "Original Field 1",
        copiedTo: "Some Other Field"
        copiedFrom: "Original Field 2"

let original = await input.recordAsync("Original Record", table)

let obj = {}

replacements.forEach(x => {
    let fieldValue = original.getCellValue(x.copiedFrom)
    let targetField = x.copiedTo ? x.copiedTo : x.copiedFrom
    let method = fieldValue && table.getField(x.copiedFrom).type=="multipleRecordLinks" ? => ({id:})) : fieldValue
    table.getField(targetField).isComputed == false && Object.assign(obj, {[targetField]: method})

await table.createRecordAsync(obj)
await table.updateRecordAsync(original, {
    "Checkbox Field Name": true,

The script was written so that it would have general applicability for others with similar use cases. For you, specifically, the replacements array be something like this:

replacements = [
        copiedFrom: "MODIFIED TITLE",
        copiedTo: "CURRENT TITLE"
        copiedFrom: "MODIFIED DESC",
        copiedTo: "CURRENT DESC"

This script again assumes the same methodology I suggested the first time, meaning you activate the button, the script runs, the script fills in the checkmark for you.

Or, if you have a Pro account you could just set up to run an Automation when a record enters a view (one that is filtered for “Checkbox = true”):

We are on a Pro Plan. I"ll read through the automation docs in the morning… THANK YOU!