Skip to main content
Solved

Script for creating record with single select field is failing

  • October 9, 2024
  • 3 replies
  • 69 views

Ruchika_Abbi1
Forum|alt.badge.img+17

I have the following script to create records in a table. 
Event Name is a Single Select field. But I get an error "
Error: Field "...." cannot accept the provided value."

 

await passTable.createRecordAsync({ "Event Name": event, "Event Date/Time": date, "Notes": notes, }); }

 

 
I tried: 

 

"Event Name": [{name: event.toString()}] and "Event Name": [{name: event)}]

 

 

but neither of them work. Any suggestions? 

Best answer by TheTimeSavingCo

Single select fields expect `{name: [OPTION VALUE]}`, so try

"Event Name": {name: event.toString()}

 or

"Event Name": {name: event}

3 replies

TheTimeSavingCo
Forum|alt.badge.img+31
  • Brainy
  • 6457 replies
  • Answer
  • October 9, 2024

Single select fields expect `{name: [OPTION VALUE]}`, so try

"Event Name": {name: event.toString()}

 or

"Event Name": {name: event}

Alexey_Gusev
Forum|alt.badge.img+25
  • Brainy
  • 1261 replies
  • October 9, 2024

Single select fields expect `{name: [OPTION VALUE]}`, so try

"Event Name": {name: event.toString()}

 or

"Event Name": {name: event}

Hi,

I remember my beginner steps in Airtable JS, such explanation would be critical for me 🙂

Your answer is correct in final part, but I would better say
Single-select refuses to get  {name: [OPTION VALUE]}
because it's array.
Single-select expects a single object with Name 

 

{name: OPTION_VALUE}

 


The `{name: [OPTION VALUE]}`, Array of objects is the format for Multiselect, Linked field, Lookup (computed, can't write to it), multi-User. maybe something else.

I would suggest to take a look in this place for cell value problems with Create/Update fields
maybe it's difficult to understand the exact format, but it usually has good examples.

Another thing to check, chatGPT sometimes reply with a brilliant answer. And sometimes it's a nonsense formatted like brilliant answer. To fix a small part of script is easier that write new from scratch.

anyway, worth a try.



Ruchika_Abbi1
Forum|alt.badge.img+17
  • Author
  • Inspiring
  • 43 replies
  • October 10, 2024

Single select fields expect `{name: [OPTION VALUE]}`, so try

"Event Name": {name: event.toString()}

 or

"Event Name": {name: event}

Ah! I see what I did wrong there🙊 Thanks!