Help

Lambda function retrieving record id instead of value (it's a lookup field)

199 1
cancel
Showing results for 
Search instead for 
Did you mean: 
jacobs
4 - Data Explorer
4 - Data Explorer

Output:

jacobs_0-1715780686982.png

Code:

 

 

     // 7. Extract and Return *Only* Desired Fields
        const productData = recordsData.records[0].fields;
        const desiredFields = {
            "Collection":  (productData.Collection && productData.Collection.length > 0) ? productData.Collection[0].fields.Name : null,
            "Color": (productData.Color && productData.Color.length > 0) ? productData.Color[0] : null,
            "Font": (productData.Font && productData.Font.length > 0) ? productData.Font[0] : null,
            "Product": (productData.Product && productData.Product.length > 0) ? productData.Product[0] : null,
            "Registration Status": productData["Registration Status"] || null,
            "Registration Date": productData["Registration Date"] || null,
            "Release Date": productData["Release Date"] || null

 

 

 

1 Reply 1
DannyM
Airtable Employee
Airtable Employee

Hi Jacobs, it's a bit hard to tell without seeing all of your code so can you confirm you are using the Airtable.js library? If you can provide your full code, that will make it easier to advise!

With regard to the screenshot of the Collection value you shared, it looks like an array of record IDs which is a common return value for Linked Record field type, not Lookup field type: https://airtable.com/developers/web/api/field-model#foreignkey

In your code, the "Collection" field seems to be a linked record field to another table (based on the return value you shared, but I can't confirm 100%), and it seems you are trying to get the `Name` of the linked record field  (if it exists, otherwise null) because `productData` represents `recordsData.records[0].fields`. So to me it seems there is a discrepancy between the return value you showed in your screenshot and the code you are running and there might be some more steps or code that I don't have context on yet. How are you outputting the values shown in your screenshot? Is that from some system, code, or environment outside of Airtable?