Created
March 6, 2020 17:08
-
-
Save on2air/ddb80c8e6ee47e5c29d8c7475f25a16e to your computer and use it in GitHub Desktop.
Field Copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let formatter = [ | |
{ | |
table: 'Formats', | |
view: '', | |
fields: [ | |
{ | |
in_field: 'Currency', | |
out_field:'Currency Text', | |
}, | |
{ | |
in_field: 'Percent', | |
out_field:'Percent Text', | |
}, | |
{ | |
in_field: 'Decimal', | |
out_field:'Decimal Text', | |
}, | |
] | |
} | |
] | |
for(let f = 0; f<formatter.length; f++){ | |
let info = formatter[f] | |
let table = base.getTable(info.table) | |
let view = info['view'] ? table.getView(info.view) : null | |
let records = view ? await view.selectRecordsAsync() : await table.selectRecordsAsync() | |
let fields = info.fields | |
for(let r=0; r<records.records.length; r++){ | |
let record = records.records[r] | |
let data = {} | |
for(let f=0; f<fields.length; f++){ | |
let field = fields[f] | |
let inField = field.in_field | |
let outField= field.out_field | |
data[outField] = record.getCellValueAsString(inField) | |
} | |
await table.updateRecordAsync(record.id, data) | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment