I am trying to find and compare exact value from a table to other.
Table A: I will insert 'Key' of other table's record. Once I insert the key, automation script will run and it will search the corresponding record.
Table B: Bunch of records are exist in this table with unique "Key".
I am trying to make script as below:
console.log("스크립트를 실행합니다.")
let tableName = "Review Ticket"
let tabledata = base.getTable(tableName);
let record_id = input.config().recordID
let record2 = await tabledata.selectRecordAsync(
record_id, {fields: ["Title", "Key", "Task to Review", "Subtask to Review", "Asset to Review"]}
)
let input_key = record2.getCellValueAsString("Key").toUpperCase()
if (input_key.charAt(0) == "T") {
var table = base.getTable("Tasks")
// var fieldName = "Title"
// var keyValue = "Key"
var queryResult = await table.selectRecordsAsync({fields: [fieldName, keyValue]})
var findKey = queryResult.records.filter(element => (
element.getCellValueAsString(keyValue) == input_key))
console.log(findKey)
console.log(queryResult.records[0].getCellValueAsString(keyValue))
await tabledata.updateRecordAsync(record2, {
'Task to Review': findKey,
});
console.log(input_key + " Task를 추가했습니다.")
}
console.log(findKey) always return '[ ]'.(returns 'undefined' in case of I use .find)
but log below returns proper value.
console.log(queryResult.records[0].getCellValueAsString(keyValue))
Please help me to solve it.