Help

Using javascript to insert multiple select values into a new record

Solved
Jump to Solution
8226 11
cancel
Showing results for 
Search instead for 
Did you mean: 
Conor_McKeever
5 - Automation Enthusiast
5 - Automation Enthusiast

Hello,

I am setting up a record to duplicate a record (but only certain fields) in a base by taking input variables and then creating a new record and inputting these into the new record as such

let recordIdNew = await table.createRecordAsync({

    "DateTest": StartDate,  

    "SingleLineText": SingleLineText,

    "PhoneNumberTest": PhoneNumberTest,

    "CheckBoxTest": CheckBoxTest,

    "LongTextTest": LongTextTest,

    "EmailTest": EmailTest,

    "SingleSelectTest": {name: SingleSelectTest},

});

 

I have managed to achieve this with all the required data formats but I’m really struggling with Multiple Select.  I am able to pull the data from the original records field and it shows in the console as follows

CONSOLE.LOG

  1. (2) ["AA""BB"]

 

The issue is, I don’t know how to add it to the new record (like I am able to do with all of the other data types)

 

I have had a look at the write data format but it doesn’t really make any sense to me at this early stage of my AirTable career.

TYPEDEF

Array<{id: string} | {name: string}>

 

I think I need to map this to a new object in the following format which I have done

CONSOLE.LOG

  1. (2) [Object, Object]
    1. ▶0: Object
      1.  name: "AAA"
    2. ▶1: Object
      1.  name: "BBB"

 

Any advice would be greatly appreciated.

 

 

11 Replies 11
Alexey_Gusev
13 - Mars
13 - Mars

I had such case in Automation too. Instead of creating record by script, I finished code with some 'output.set's, using these values in a next 'Create record' step. 

Alexey_Gusev_0-1674542837449.png

 

 

Kamille covers this topic (and limitation) well in the latest BuiltOnAir Podcast;

https://www.youtube.com/watch?v=81GDyLVFAy8

airtable #on2air #builtonair 1/17/2023 - BuiltOnAir Live Podcast Full Show - S13-E02 ___________________________ The BuiltOnAir podcast is a live weekly show highlighting everything happening in the Airtable universe. Check us out at BuiltOnAir.com/join. Join our community, join our Slack channel