Skip to content

Instantly share code, notes, and snippets.

@on2air
Created March 6, 2020 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save on2air/ddb80c8e6ee47e5c29d8c7475f25a16e to your computer and use it in GitHub Desktop.
Save on2air/ddb80c8e6ee47e5c29d8c7475f25a16e to your computer and use it in GitHub Desktop.
Field Copy
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