Skip to main content
Solved

Update single Select Status in my script

  • June 12, 2022
  • 2 replies
  • 35 views

Drew_Nemer
Forum|alt.badge.img+20

I have a single select field named “STATUS” and I want to configure a button that would copy a record with all the following attributes and then make that new duplicate record’s STATUS set to “Voucher Re-Issued”.

Below is the script I use to duplicate the record, I just not sure where or how to configure the STATUS to “Voucher Re-Issued”

let table = base.getTable("Relocation")
let query = await table.selectRecordsAsync()
let records = query.records

let fields = table.fields

let exclude = ["UNIT ADDRESS [FULL]", "BR", "UNIT FAILED OUTCOME", "Voucher Expiration Date", "STATUS", "UNIT QUALITIES", "PENDING PO DOCS", "LEASE-UP SELECT", "PENDING DOC/VERIFICATION (TENANT)", "STREET ADDRESS", "CITY", "ZIP CODE", "YEAR", "W9", "Owner Name", "UNIT #", "Lease Up", "Data Entry Complete"]

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)

Best answer by Kamille_Parks11

just above your await line you could add

obj["STATUS"] = {name: "Voucher Re-Issued"}

or something similar.

2 replies

Kamille_Parks11
Forum|alt.badge.img+27
  • Brainy
  • 2679 replies
  • Answer
  • June 12, 2022

just above your await line you could add

obj["STATUS"] = {name: "Voucher Re-Issued"}

or something similar.


Drew_Nemer
Forum|alt.badge.img+20
  • Author
  • Known Participant
  • 36 replies
  • June 13, 2022

just above your await line you could add

obj["STATUS"] = {name: "Voucher Re-Issued"}

or something similar.


Thank you! This is perfect