- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 04:37 AM
Hi, I hope it's ok to ask for some human help here. Like many, i'm sure, I've been getting OpenAI to help me out when my coding doesn't work, and for the most part that's been fine. But i'm stuck on something now.
I have a script which takes a 'booking' (which is a record in a Bookings table), looks at the linked record for {Episode} and {Element} and increments the number found within each by 1. It then searches up those records in the relevant tables "Episodes" and "Elements" and tries to create a new record with those found RecordIDs in the relevant fields. I am getting stuck as the script reports that the fields in question (which I've confirmed are correct IDs) won't accept the RecordIDs in the format they are being given.
The fields are linked records, able to accept multiple records, so I think the script is presenting the RecordIDs as an array. the script is below, and also the error I receive.
The error I get is:
- "Searching for "Mr *** 102" in Episodes"
CONSOLE.LOG
- "Found matching record "Mr *** 102" with ID recQ3WRDltScngM4W in Episodes"
CONSOLE.LOG
- "Searching for "MBS 102 Foley record" in Mix Elements"
CONSOLE.LOG
- "Found matching record "MBS 102 Foley record" with ID recW8ts94WGLesW83 in Mix Elements"
CONSOLE.LOG
- "Attempting to create record with new Episode ID: ["recQ3WRDltScngM4W"] and Element ID: ["recW8ts94WGLesW83"]"
CONSOLE.ERROR
- "Error creating record: a: Field "fldUVZDMOGZpHpgnS" cannot accept the provided value."
[I redacted some data in the episode name for privacy issues]
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 04:37 AM
As I've been dealing with AI Bots all day, I forgot to say "thank you for your help!"
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 05:54 AM
Hi there! I think you’re close - in your function “findNextRecordId”, you’re returning “[found.id]” which is an array of one string.
A linked record field expects an array of objects, not strings.
Try changing that function to return “[{id: found.id}]” instead of “[found.id]” - I think that should do the trick 😊
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 06:23 AM
Incredible! Thank you so much, you were absolutely right. I've adjusted that and it now works. Thank you so much
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 07:37 AM
Hi,
Would like to suggest, if you have questions in future, use
it helps quickly distinguish code block
// Retrieve the trigger record
let record = await bookingsTable.selectRecordAsync(recordId);
let numberOfDuplicates = record.getCellValue("Duplicates") ? parseInt(record.getCellValue("Duplicates"), 10) : 1;
numberOfDuplicates = Math.max(1, numberOfDuplicates); // Ensure at least one duplicate
console.log(`Creating ${numberOfDuplicates} duplicates for record ID ${recordId}`);
from a piece of usual text.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Mar 21, 2024 07:41 AM
ah yes fantastic, thank you i will. Did think it was likely there was a better way of presenting my info