Skip to main content

I am receiving a cryptic error when attempting to create a record using the code below:

// Change this name to use a different table let table = base.getTable("Touchpoints"); //let ctable = base.getTable("Contact"); // Prompt the user to pick a record // If this script is run from a button field, this will use the button's record instead. let record = await input.recordAsync('Select a record to use', table); let billTillString = await input.textAsync('Bill Orders till which date? (format YYYY-MM-DD)'); //let notes = await input.textAsync('Any Notes to mention'); let billTillDate = new Date(billTillString); /* //newRecs[0]['id'] = 'recDYGIT7fj80tTAH'; //let namer = new Array('recDYGIT7fj80tTAH'); //let Contact = record.getCellValueAsString("Contact"); // Contact RecordID //let recordID = record.getCellValueAsString("Contact RecordID"); //console.log("ID is: " + recordID); */ await table.createRecordAsync({ 'Start Date/Time': billTillDate, 'Contact': [{id: 'recI7YlIh4jJkUiYT'}], 'Notes': 'Sample Note' }); /* console.log(billTillDate); if (record) { // Customize this section to handle the selected record // You can use record.getCellValue("Field name") to access // cell values from the record console.log(record.id); } else { output.text('No record was selected'); } */

https://share.getcloudapp.com/NQuWLz8y

It's also INCREDIBLY slow - any input or ideas would be much appreciated. Thank you!

P.S. I'm just trying to create a new record with a date which is inputted along with a linked record.

Video for context: https://share.getcloudapp.com/d5ugL4Z6

https://share.getcloudapp.com/xQuRPZPP

Fore more context on the crash that happens on a linked record


You don't say the field type for your {Start Date/Time} field, but I'm guessing that it is a date field. You need to convert the date to an ISO 8601 string, per the documentation.

 

'Start Date/Time': billTillDate.toISOString(),

 

 


You don't say the field type for your {Start Date/Time} field, but I'm guessing that it is a date field. You need to convert the date to an ISO 8601 string, per the documentation.

 

'Start Date/Time': billTillDate.toISOString(),

 

 


Thank you so much for your reply!

Unfortunately even when removing all references to Date the app still crashes. Video below provides more context:

https://share.getcloudapp.com/wbuDjr5g


This issue is fixed, I updated to the following code and it's all working now 🙂

 

let table = base.getTable("Touchpoints"); let cTable = base.getTable("Contact"); let trecord = await input.recordAsync('Select a record to use', table); let callBack = await input.textAsync('What is the callback date? (YYYY-MM-DD)'); let notes = await input.textAsync('Include any callback notes'); let callDate = new Date(callBack); let recordID = trecord.getCellValueAsString("Email"); let query = await cTable.selectRecordsAsync(); // Replace "example@example.com" with the email address you want to search for let emailToSearch = trecord.getCellValueAsString("Email"); let record = query.records.find(record => record.getCellValue("Email") === emailToSearch); if (record) { // Do something with the record, such as log it to the console await base.getTable('Touchpoints').createRecordAsync({ 'Start Date/Time': callDate, 'Notes': notes, 'Type': { name: 'Call Back' }, 'Contact': [{id: record.id}] }); console.log(record); } else { console.log(`Record with email ${emailToSearch} not found.`); }

You don't say the field type for your {Start Date/Time} field, but I'm guessing that it is a date field. You need to convert the date to an ISO 8601 string, per the documentation.

 

'Start Date/Time': billTillDate.toISOString(),

 

 


Thank you so much! This did end up working - much appreciated!