I'm attempting to create a number of placement records, linking to a booking where the number of records is inputted by the user.
I've cobbled together pieces from various example scripts I've found, but I'm hitting an error. Please see details below.
This is the script:
This is the error:
And these are the details of the object:
Currently I suspect there's a type mismatch somewhere - but any help would be greatly appreciated!
Best answer by TheTimeSavingCo
Thanks!
Could you try swapping the following:
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync([
{
fields: {
'Event ID': [{id: bookingId}]
},
}
])
console.log(i)
}
To this?
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync({
'Event ID': [{id: bookingId.id}]
})
console.log(i)
}
You were using the format for 'createRecordsAsync()' instead of 'createRecordAsync()'.
I would also recommend renaming 'bookingId' to 'bookingRecord' as the user selects the record at that point and not the id, which is why I modified the line to `[{id: bookingId.id}]` as well
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync([
{
fields: {
'Event ID': [{id: bookingId}]
},
}
])
console.log(i)
}
To this?
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync({
'Event ID': [{id: bookingId.id}]
})
console.log(i)
}
You were using the format for 'createRecordsAsync()' instead of 'createRecordAsync()'.
I would also recommend renaming 'bookingId' to 'bookingRecord' as the user selects the record at that point and not the id, which is why I modified the line to `[{id: bookingId.id}]` as well
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync([
{
fields: {
'Event ID': [{id: bookingId}]
},
}
])
console.log(i)
}
To this?
for (let i = 0; i < Number(performers); i++ ) {
await placements.createRecordAsync({
'Event ID': [{id: bookingId.id}]
})
console.log(i)
}
You were using the format for 'createRecordsAsync()' instead of 'createRecordAsync()'.
I would also recommend renaming 'bookingId' to 'bookingRecord' as the user selects the record at that point and not the id, which is why I modified the line to `[{id: bookingId.id}]` as well
@TheTimeSavingCo you are legendary - works like a charm! Such a silly error to have used the wrong format for the method.
I really appreciate the assistance, as well as the tip for bookingRecord. I'm still getting my head around literals following me through tables, rather than FKs.