Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Jun 02, 2022 04:48 AM
Hi there :slightly_smiling_face:
I’m new to coding and Airtable and I need some assistance.
My script is to update a record with user input. The issue I’m running into is in line 7. The script runs but I’m assuming it is this error that stops it from actually updating the cell. I understand the error but I’m just not sure how to remedy it. I’d also like to know how to output the new_date variable within the text output line above it.
Solved! Go to Solution.
Jun 03, 2022 05:25 AM
You are getting the squiggly red underline that says “record is possibly null” because it will be null if the user closes the record picker without selecting a record.
Your other issue is that a date field need to be set to an ISO date string. You cannot use Airtable formulas to parse the date. You need to use JavaScript to parse the date and then convert the date to an ISO string.
Jun 02, 2022 09:03 AM
Hi @Sarah_Viljoen
Your variable record should return two items, id and name. I think you need to pass the id into the update. So record.id
Jun 03, 2022 12:36 AM
Hi @Vivid-Squid
I tried that but then it says “Object is possibly null” and it doesn’t work. I also then have the issue (I think this is the issue) where the string passed into new_date by the user needs to be a date variable, not string. I’ve tried using DATETIME_PARSE() to convert it to a date but it isn’t recognizing the argument at all.
Jun 03, 2022 05:25 AM
You are getting the squiggly red underline that says “record is possibly null” because it will be null if the user closes the record picker without selecting a record.
Your other issue is that a date field need to be set to an ISO date string. You cannot use Airtable formulas to parse the date. You need to use JavaScript to parse the date and then convert the date to an ISO string.
Jun 03, 2022 05:55 AM
Thank you so much ! I will go check out how to use JavaScript to do that and I’ll come back with any questions if I’m still having issues.
Jun 06, 2022 01:45 AM
This is probably a very simple issue but I can’t seem to get it right. I’m still having trouble with converting a string variable to a date. My ESC DATE field is a date field and it’s where the user input will go. I just need to convert what the user inputs (they are prompted to type it as ‘Month Day, Year’) to a variable type that will be compatible with my date field. I checked out the links you kindly provided me with but I’m still confused.
Jun 07, 2022 12:28 AM
@kuovonne I got it working ! I played around using the links you provided. Thanks so much for all the help ! @Vivid-Squid, the ‘record.id’ does work, I just thought it didn’t because of the red squiggly line. Thanks for helping me !