Need help creating custom itemized list. combing a referenced field and serial # field into one field

Lets say I have two databases. One is for people, we use their initials as reference. The other is for details about their submissions (of which there are over 5000 I need to import/assign). I need to create a new field that concatenates “person’s initials”“submisson number” into something like MS1001, MS1002, MS1003… while the another person (KJ) is KJ1001, KJ1002, KJ1003, and yet another person is LP1001…

Dataset is Registry
initials, serial, and submission are fields in Registry

below is the code I have… its not working. there is an error on the line . I’m really failing to understand why this is not working.

$w(“#Registry”).setFieldValue(“submission”, $w(“#initials”).text + $w(“#serial”).number);

Data Hook

import wixData from “wix-data”; // you’ll need this too

export function Registry_beforeInsert(item, context) {
return wixData.query(“Registry”)
.limit(1)
.descending(‘serial’)
.find()
.then((results) => {
if (results.length === 0) {
item.serial = 1;
} else {
const lastItemInCollection = results.items[0];
item.serial = lastItemInCollection.serial + 1;
}
return item;
});
}


Page

import wixData from “wix-data”;
const record = {
“serial”: 0
};
wixData.insert(“Registry”, record)
. catch ((err) => {
console.log(“error”, err);
});
$w(“#Registry”).onReady( () => {
$w(“#Registry”). new ()
.then( ( ) => {
$w(“#Registry”).setFieldValue(“submission”, $w(“#initials”).text + $w(“#serial”).number);
$w(“#Registry”).save();
} )
. catch ( (err) => {
let errMsg = err;
} );
} );

Hi,
to take a closer look into the issue, please send the following details:
Step by step the exact functionality you wish to achieve with your code.
What’s exactly the error you receive (screenshot if possible).
Link to your site’s editor.
Name of the page with the issue.