Retrieving data from Privatemembersdata using dataset

Greetings,
I’m trying to allow loggedin users pull their data from their membersprivate data and save to another field in a different collection. This is my code but seems the data is not being retrieved. #dataset22 is connected to Membersprivateddata(read only). Any help will be appreciated.

export function button300_click(event) { 
 let phone = $w("#dataset22").getCurrentItem().mainPhone;
 if ($w("#input9").value > 1 ) {
        $w("#dataset21").setFieldValues({

 "status": 'Pending',
 "phoneNumber": phone,
 
        });
        $w("#dataset21").save();
 //Add your code for this event here: 
}}

Hello paiy.surv,

just tested your code and it works for me, even without using (onReady).

export function button300_click(event) { 
 let title = $w("#dataset22").getCurrentItem().title;
 if ($w("#input9").value > 1 ) {
        $w("#dataset21").setFieldValues({
//          "status": 'Pending',
 "title": title
        });
        $w("#dataset21").save();
    }
}

Hi :raised_hand_with_fingers_splayed:

setFieldValues() function must be placed inside the dataset’s onBeforeSave() function, inside the dataset’s onReady() function.

Ahmad

My #dataset22 connects to private members data. did you try that out?

This way?

export function button300_click(event) { 
 let title = $w("#dataset22").getCurrentItem().title;
 if ($w("#input9").value > 1 ) {
        $w("#dataset21").setFieldValues({
//          "status": 'Pending',
 "title": title,
         $w("#dataset21").save();
        });
    }
}

Check following similar example here…

https://russian-dima.wixsite.com/meinewebsite/dublicate-database

$w.onReady(function () {
 let itemObj 
    $w('#dataset1').onReady( () => {
 
    $w('#button1').onClick(()=>{
        itemObj = $w('#dataset1').getCurrentItem();
        console.log(itemObj)
        console.log(itemObj.title)
 
        $w("#dataset2").onReady(() => {
            $w('#dataset2').setFieldValue('title', itemObj.title)
            $w('#dataset2').save()
        })
    })
 
    $w('#button2').onClick(()=>{$w('#TXTinfo').text = $w('#dataset1').getCurrentItem().title})
    $w('#button3').onClick(()=>{$w('#TXTinfo').text = $w('#dataset1').getCurrentItem().title})
    })
});

DATASET-1 = READ-ONLY
DATASET-2 = WRITE-ONLY

No “onBeforeSave() function” was utilized, but it still works.
So on my opinion, there is no need for it. But this is just a theoretical thought.

If you want to work with “PrivateMembersData”, then you have to log in.

Could you find a solution?

I will try out this then get back to you