Save field from dataset to another dataset

hi to everyone,

I searched for various solutions, I tried to write this code using insertReference. It does not report errors, but it does not work.
I simply have to read the IDCode present in the field of collection A (DTS2) and write it in the same field referenced in the collection named “AssociativeSpace”.

Can you help me please?

Thanks in advance as always


export function BServiceOnline_click(event) {
let CompanyCode = $w(“#DTS2”).getCurrentItem().IDCode
wixData.insertReference(“AssociativeSpace”, “IDCode”, “” , CompanyCode)
.then(() => {
console.log(“Reference inserted”);
})
}