Button linked to dynamic page working in preview but not in live

Hi guys can anyone explain why a button works in preview mode but not in live, it’s in the main member details page, i have 2 datasets running within the page and linked to two separate db filtered to logged in user but even with disabling the one it still doesn’t work, also when in preview the one dataset navigates to a completely different profile to whats logged in?

Hard to help you without any code, data, or pic.

  • do you use a code ?

Did you have checked the permissions of the data-collection/dataset?

hi buddy yes i use code but not on the buttons, also the permissions are all set fine

also this is the site code for logging in i use two buttons on the header for that



import wixUsers from 'wix-users';
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
// import { displayNotifications } from 'public/SK-Notes';

/*
const hasNotifications = 'wix:vector://v1/848f2af4c8f14a6aac59be8255ce9b83.svg/848f2af4c8f14a6aac59be8255ce9b83.svg',
    hasNone = 'wix:vector://v1/848f2af4c8f14a6aac59be8255ce9b83.svg/848f2af4c8f14a6aac59be8255ce9b83.svg',
    slideOptions = {
        "duration": 1200,
        "direction": "top"
    };
*/
let usrID;

$w.onReady(() => {
 // displayNotifications('notDropdown', {
 //  trigger: 'icon',
 //  display: 'counts',
 //  has: hasNotifications,
 //  notHas: hasNone,
 //  animation: slideOptions,
 // });
 if (wixUsers.currentUser.loggedIn) {
        $w("#button4").label = "Logout";

        $w("#button5").show();
        usrID = wixUsers.currentUser.id;
    } else {
        $w("#button4").label = "Trade's Login";

        $w("#button5").hide();
    }
});

export function button4_click(event) {
 // user is logged in
 if (wixUsers.currentUser.loggedIn) {
 // log the user out
        wixUsers.logout()
            .then(() => {
 // update buttons accordingly
                $w("#button4").label = "Trade's Login";
                $w("#button5").hide();
            });
    }
 // user is logged out
 else {
 let userId;
 let userEmail;

 // prompt the user to log in 
        wixUsers.promptLogin({ "mode": "login" })
            .then((user) => {
                userId = user.id;
 return user.getEmail();
            })
            .then((email) => {
 // check if there is an item for the user in the collection
                userEmail = email;
 return wixData.query("MemberProfile")
                    .eq("_id", userId)
                    .find();
            })
            .then((results) => {
 // if an item for the user is not found
 if (results.items.length === 0) {
 // create an item
 const toInsert = {
 "_id": userId,
 "email": userEmail
                    };
 // add the item to the collection
                    wixData.insert("", toInsert)
                        .catch((err) => {
                            console.log(err);
                        });
                }
 // update buttons accordingly
                $w("#button4").label = "Logout";
                $w("#button5").show();
            })
            .catch((err) => {
                console.log(err);
            });
    }
}


export function button5_click() {
    wixLocation.to(`/account/my-account`);
}



hi buddy i found the issue within the site code it was only inserting user id’s into one Db “MemberProfile” on login so the one dataset was useless it was querying my other ApproveApplications db and there was no id’s being stored in there to pull from, so the question is how do we query 2 databases in the site code

Ive tried the following but it only inserts the id into 1 db and not both


            .then((user) => {
                userId = user.id;
 return user.getEmail();
            })
            .then((email) => {
 // check if there is an item for the user in the collection
                userEmail = email;
 return wixData.query("ApproveApplication") &&("MemberProfile")
                    .eq("_id", userId)
                    .find();
            })
            .then((results) => {
 // if an item for the user is not found
 if (results.items.length === 0) {
 // create an item
 const toInsert = {
 "_id": userId,
 "email": userEmail
                    };