Help

Multiple Linked Records keep overriding

Topic Labels: Scripting extentions
643 0
cancel
Showing results for 
Search instead for 
Did you mean: 
Arwel_Brown
4 - Data Explorer
4 - Data Explorer

Hi guys!

I’m attempting to fill in a field with linked records from another table. The values being entered are flight names based on flight confirmations. As flight confirmations go, they often have multiple flights on them. For some reason, even when using the method outlined in the scripting reference, my values are still overriding. Annoyingly, I can quite literally see this happening by watching the table after running the script - so I know the extra flights are going in the right place, they just don’t want to play nicely with all the other flights! The code snippet that’s updating the flights is below, hope someone can help!

    if (flights !== undefined && flights.length > 0) {
        // INSERT FIRST FLIGHT
        let updateRecord = await passengerFlightsTable.updateRecordAsync(record, {
            'Flight Name': [{
                id: flights[0].getFlightID()
            }]
        });

        flights.shift(); // get rid of first flight so one-wayers are accounted for

        if (flights.length > 0) {
            let newForeignRecordIdToLink = flights[0].getFlightID();
            passengerFlightsTable.updateRecordAsync(record, {
                'Flight Name': [...record.getCellValue('Flight Name'), {id: newForeignRecordIdToLink}]
            });

            flights.shift();
        }
    }

Update - I have tried awaiting the async method, no joy there either

0 Replies 0