How to move data from one database collection to another 2020

Hello! You may notice this post is very similar to one from 2018. That’s because I have almost exactly the same workflow and request as the OP did in 2018 and a true solution was never found.

I have a great idea but struggling with how to make it work.

On the website I created to database collections: before verification and after verification .
I am using this for user submitted photos of their painted models which they purchased from me. I am looking to collect the following information (each one a field in the DB entry)
Picture
Model Name
Submitted By
Painted By
Email Address
May we display this in our gallery? (Boolean Y|N)
Note

Here is the desired workflow:

Step 1: Users submit their information through user input fields. Right now it successfully goes to before verification database . This information is available in the form on the dynamic admin page and not to other users before verification. I successfully made this step!

Step 2: Admin should make sure that the information from the user is correct and appropriate. Once he clicks the “approval” button I want SOME information to transfer from before verification to after verification database that sends information to the pro gallery available to everyone.
The information I want transferred is STRICTLY what will be used and displayed in the gallery:
Picture
Model Name
Painted By

I don’t know how to complete this step.

Problem:
Before verification and after verification databases have read&write settings. Right now the admin page takes the information from before verification database . I created the submit button and connected it to after verification database . Unfortunately, when the admin clicks the approval button (meaning submit this information to after verification database ) it creates the blank row in the after verification database and do not move the information from before the verification database.

I was able to kind of elegantly make this work with a single database by adding another boolean field besides the user provided one. The field is simply called “Admin Approved”, I then set two filter rules in the gallery for those two boolean fields requiring a YES before displaying the image in the gallery.
But here comes the massive security issue… In order for this to work I must allow this single DB to have “Everyone Read and Create” permissions. I had a pretty saavy friend of mine run some penetration and exposure tests on the gallery page and he was able to pull the entire database including fields that were not used in the gallery such as email address, note, submitted by, etc.

Can someone tell me how to fix the issue? I am by no means a web developer. I went with Wix because of the touted ease of use and pixel perfect designer. Yet I find this to be a pretty glaring security flaw. I contacted WIX support and was told I could either hand duplicate the entries myself or I could jump on here and ask you amazing people for help.

So here I am :slight_smile:
I tried researching until I went crosseyed, I promise. Please go easy on me, it’s my first post here.

Thank you all in advance for taking the time to read my request and trying to help if you reply.

Hi Patrick and welcome to the Corvid Community.

Saving data to a collection is achieved by wixData insert .

First replace the existing submit/approve button with a new custom button, write code to get the desired fields, then save the data to the 2nd collection using wixData insert.

https://www.wix.com/corvid/reference/wix-data.html#insert

If you are less willing to dive into code you can always hire a Corvid dev
https://www.wix.com/corvid/forum/community-discussion/need-a-little-help-with-your-site-hire-a-corvid-web-developer

Good luck!

Hi you can use this code work perfect, let me know

$w.onReady(function () {
let itemObj
$w(‘#dataset1’).onReady( () => {

$w(‘#button4’).onClick(()=>{
itemObj = $w(‘#dataset1’).getCurrentItem();
console.log(itemObj)
console.log(itemObj.title)
console.log(itemObj.make)
console.log(itemObj.model)

$w(“#dataset3”).onReady(() => {
$w(‘#dataset3’).setFieldValue(‘title’, itemObj.title)
$w(‘#dataset3’).setFieldValue(‘make’, itemObj.make)
$w(‘#dataset3’).setFieldValue(‘model’, itemObj.model)
$w(‘#dataset3’).save()

})
})

$w(‘#button4’).onClick(()=>{$w(‘#input1’).value = $w(‘#dataset1’).getCurrentItem().title})
$w(‘#button4’).onClick(()=>{$w(‘#input2’).value =$w(‘#dataset1’).getCurrentItem().make})
$w(‘#button4’).onClick(()=>{$w(‘#input3’).value=$w(‘#dataset1’).getCurrentItem().model})
})

});