Pushing Data to Table
# 🤝help
s
Love exploring the new table features! I've been able to pull data from the table but I'm having a hard time pushing data to the table. Attached is my table, its just two columns: storeDescription, Item. How can I push data to this like in the office hours execute code example? I tried the following but I'm much more familiar with C# so I'm not sure what I'm doing wrong. const items = ['Pro Panel', 'Classic Rib'].map((item) => ({ item, storeDescription: 'This is a fake item' })) await ExampleData.createRecords([...items])

https://cdn.discordapp.com/attachments/1131659426806374410/1131659427099979806/image.png

https://cdn.discordapp.com/attachments/1131659426806374410/1131659427385200771/image.png

c
@witty-football-93730 will be able to help here 🙂
s
Thanks! 🙂
w
Hey @straight-wolf-37371 Do you get an error ? if yes, what's the error you're getting ?
s
Ahhhh, yeah that would be helpful wouldn't it. I saw that the docs were published and figured out a lot of stuff yesterday, I'll try again today and see if I get an error.
w
Oh I know what's the issue it's quite simple
In your code you need to use the right keys inclluding casing 🙂
Copy code
const items = ['Pro Panel', 'Classic Rib'].map((item) => ({
  Item: item,
  "Store Description": 'This is a fake item'
}))

await ExampleData.createRecords(items)
s
Thank you! I will try this. I figured out quite a lot with finding records. Created this to look through the table to find specific entities. Tables are great! 🙂
Copy code
const fetchRecords = async () => {
  try {
    const recordData = await Character_DataTable.findRecords({})

    workflow.recordsFound = []

    // Get All Ability Records
    for (const ability of workflow.abilitiesInQuestion) {
      for (const record of recordData) {
        console.log('Checking match between: ' + record.Ability_Name + ' and ' + ability)
        if (record.Ability_Name === ability) {
          console.log('Found Matching Record: ' + record.Ability_Name)
          workflow.recordsFound.push(record)
        }
      }
    }

    // Get All Character Abilities
    for (const character of workflow.charactersInQuestion) {
      for (const record of recordData) {
        console.log('Checking match between: ' + record.Ability_Owner + ' and ' + character)
        if (record.Ability_Owner === character) {
          console.log('Found Matching Record: ' + record.Ability_Owner)
          workflow.recordsFound.push(record)
        }
      }
    }
  } catch (error) {
    console.error('Error fetching records:', error)
  }
}

await fetchRecords()

console.log("I found " + workflow.recordsFound.length + " records")
workflow.recordsFound = _.uniqBy(workflow.recordsFound, 'id')
w
This looks nice, stay tuned though. soon you'll be able to perform find records with queries built at run time instead of relying on selectors or doing just like you're doing now
s
Can't wait 🙂 I figured that was in the works. This is just helping me learn the system and JavaScript