Can you create multiple records in a table based on a variable?

I’m building an app that updates a data table. I can’t find a way to create new rows in the table based on a variable (ie, on row per student and the number of students is a variable). The documentation says createRecord can’t be in a loop because of the callback. But, there isn’t a createRecords function that takes an array of objects, similar to how readRecords works. I tried a Javascript function that isn’t part of App Lab (this sometimes works), but App Lab said the function wasn’t defined. My only option, it seems, it to hard code the number of students and the number of subjects and use one createRecord at a time, but that hurts me to write such awful code. Is there a way to create multiple records based on a variable in App Lab?

  • Carol Ramsey

There is no technical reason you can’t use createRecord in a loop. It is just inefficient to use a function expression. To get around that define your callback as a named function and use that instead of a function expression.

1 Like

AWESOME! Thanks!

  • Carol

Hi J. Don Wells. You have been a great help. Only if you have time, could you check out my next issue with records?

I would appreciate it!

Carol Ramsey