Insert Multiple Referenced Items with Code

Hi Guys

Has anyone managed to successfully insert multiple reference items with code? Use case: We are creating a campaign and midway through we add a few founding members. Before inserting all my campaign data, I get the founder ID’s, store it as an array and then want to insert it into my ‘Founders’ field in the database which is referenced to my Founders collection under the setting ‘Multiple items’.

I’ve gone as for as to hardcode it ID’s but still can’t get them to show up. Any ideas…?

function insertData() {
 let toInsert = {
 "campaignTitle": $w("#input19").value,
 "companyBio": $w("#textBox1").value,
 "campaignWebsite": $w("#input20").value,
 "founders": ["18bf9a79-2571-45f6-9ab2-69eb75dcee95", "cee5b5ec-90b2-4150-ae52-cf14daf5b20a", "93d6ac3d-de9f-48b9-beec-e1dc02de333c"]
        };

        wixData.insert("Campaigns", toInsert)

Thank you
Tiaan

Hey! I’m moving this to the Corvid category for better visibility :slight_smile: