Hi, I'm having Problems with a Script, that are very weird.
I'm writing a Script that should pull Crypto Prices from CoinMarketCap. For that, I created a Table "Currencies". In this Table there are 3 Fields (for the sake of this example): "Name", "Symbol", "Price". Now in the Script Settings you can enter your API Key (not relevant here), the Table of the Currencies and a Symbol and Price Field. Now the Script should query all Symbols existing on the Table, compile them into a Comma-Separated List and query the API. Then it should fill in the Price for each Symbol. This is the Code so far:
const config = input.config({
title: 'Crypto Price Importer',
items: [
input.config.text('API_KEY', {
label: 'API KEY'
}),
input.config.table('TABLE', {
label: 'Table',
}),
input.config.field('SYMBOL', {
label: 'Symbol Field',
parentTable: 'TABLE'
}),
input.config.field('PRICE', {
label: 'Price Field',
parentTable: 'TABLE'
})
]
});
const selectedTable = config.TABLE;
const selectedSymbolField = config.SYMBOL;
const selectedPriceField = config.PRICE;
const query = selectedTable.selectRecordsAsync({
fields: [selectedSymbolField, selectedPriceField]
});
const symbolList = (await query).records
.map(record => record[selectedSymbolField.name])
.filter(record => record)
.join(',');
console.log(symbolList)
The Problem now is that whenever I try to run this (note there is no API Call yet), it gives me an empty String. Upon some digging, I found that selectRecordsAsync().records only returns the "id" and the "name" Fields of the Records, not the "SYMBOL" and "PRICE" Fields. Honestly I am running out of ideas, maybe somebody can help, or explain why that is.