Skip to main content

I'm a scripting newbie and need a little help...

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! 

 

Could you provide a screenshot of the relevant tables, or even better, a link to the base with dummy data please?


Could you provide a screenshot of the relevant tables, or even better, a link to the base with dummy data please?


Hey @TheTimeSavingCo 

Thanks so much for the response. Here's a link to the base.  

(FYI: Since posting, I've changed the primary key on the joining table (Events people offerings) with a formula)


Hey @TheTimeSavingCo 

Thanks so much for the response. Here's a link to the base.  

(FYI: Since posting, I've changed the primary key on the joining table (Events people offerings) with a formula)


I should note that the script is on dashboard 2


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


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


@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.


Reply