You could use a script like this:
let table = base.getTable("Table Name")
let query = await table.selectRecordsAsync()
let records = query.records
let fields = table.fields
let exclude = ["Field 1", "Field 2"]
let filteredFields = fields.filter(x => !exclude.includes(x.name) && x.isComputed == false)
let original = await input.recordAsync("Original Record", table)
let obj = {}
filteredFields.map(x => {
Object.assign(obj, {[x.name]: original.getCellValue(x.name)})
})
await table.createRecordAsync(obj)
The above script lets you add as many fields to the exclude
array as you want. When you run the script it will ask which record you want to duplicate, then it will make a new identical record with all the fields filled in except for the fields you added to exclude
.
You could use a script like this:
let table = base.getTable("Table Name")
let query = await table.selectRecordsAsync()
let records = query.records
let fields = table.fields
let exclude = ["Field 1", "Field 2"]
let filteredFields = fields.filter(x => !exclude.includes(x.name) && x.isComputed == false)
let original = await input.recordAsync("Original Record", table)
let obj = {}
filteredFields.map(x => {
Object.assign(obj, {[x.name]: original.getCellValue(x.name)})
})
await table.createRecordAsync(obj)
The above script lets you add as many fields to the exclude
array as you want. When you run the script it will ask which record you want to duplicate, then it will make a new identical record with all the fields filled in except for the fields you added to exclude
.
That worked beautifully! This may be asking too much, but is there a way to add the link to the base item? @Kamille_Parks
That worked beautifully! This may be asking too much, but is there a way to add the link to the base item? @Kamille_Parks
What do you mean by link, the url for a particular record, or updating the value of a link-record field?
What do you mean by link, the url for a particular record, or updating the value of a link-record field?
@Kamille_Parks either really, but a link-record field was what I had in mind.
In your original post you said
regardless, adjust the filteredFields.map
section to the following:
filteredFields.map(x => {
let fieldValue = original.getCellValue(x.name)
let method = fieldValue && x.type=="multipleRecordLinks" ? fieldValue.map(y => ({id: y.id})) : fieldValue
Object.assign(obj, { x.name]: method})
})
In your original post you said
regardless, adjust the filteredFields.map
section to the following:
filteredFields.map(x => {
let fieldValue = original.getCellValue(x.name)
let method = fieldValue && x.type=="multipleRecordLinks" ? fieldValue.map(y => ({id: y.id})) : fieldValue
Object.assign(obj, { x.name]: method})
})
Thank you! I just want to have a link to the base item.
You could use a script like this:
let table = base.getTable("Table Name")
let query = await table.selectRecordsAsync()
let records = query.records
let fields = table.fields
let exclude = ["Field 1", "Field 2"]
let filteredFields = fields.filter(x => !exclude.includes(x.name) && x.isComputed == false)
let original = await input.recordAsync("Original Record", table)
let obj = {}
filteredFields.map(x => {
Object.assign(obj, {[x.name]: original.getCellValue(x.name)})
})
await table.createRecordAsync(obj)
The above script lets you add as many fields to the exclude
array as you want. When you run the script it will ask which record you want to duplicate, then it will make a new identical record with all the fields filled in except for the fields you added to exclude
.
This code doesn't work.