How to create a duplicate file in a database from the client side?

Hi Billy Rae,

This code will get you fairly close. There will likely be some tweaking needed to get the new record to display in the table where you would prefer.

export function cmdDuplicate_click(event) {
     // Create object of current record's data, assuming that you are using a dataset called "dataset1".
     let item = $w('#dataset1').getCurrentItem();
     // Assign new value to instrNumber or whatever you're calling this field
     item.instrNumber= "123456789";
     // Allow Wix to create a new _id value.  If you don't remove _id from the object, it will not insert 
     // the record since a record with that _id value already exists in the collection.
     delete item._id;
     console.log(item);
     // Insert directly into the collection housing the data.
     wixData.insert("CollectionName", item)
     .then( (results) => {
        console.log(results);
        // Since data was inserted directly into the collection, the dataset needs to be refreshed.
        $w('#dataset1').refresh();
      } )
    .catch( (err) => {
       let errorMsg = err;
    } );
}

Thank You, thank you, thank you. I will test this shortly. Looks to me like that is the solution.

You my friend are a life saver. That worked perfectly! Again thank you very, very much.