Hello,
How can i fetch column information based on field key instead of it resulting out row information?
I need a code that will know which client # (column) from the “complete menu” to grab the information from instead of it matching the information based on the row which i have already firgured out (see code below).
each client has different pricing, so i need it to results out their price based on the test code number that they are seeing on the dynamic page and the logged in user.
I have two databases. “Client” and “CompleteMenu”
-
“Client”
a. Field Keys:
i. Email
iii. Client Name -
“Complete Menu”
a. Field Keys:
i. Test Code
ii. Test Name
iii. Client 1
iv. Client 2
v. Client 3
I think the below code is what i need to update instead of firstItem.Price_id i need it to look at each client and have it know which client column to actually look at.
.then((results) => {
if (results.totalCount) {
let items = results.items;
let firstItem = items[0];
$w("#txtPrice").text = firstItem.Price_id;
So far i have only been able to create a code that grabs information from a row that matches the information.
See complete code below
import wixLocation from 'wix-location';
import wixUsers from 'wix-users';
import wixData from 'wix-data';
$w.onReady(function () {
$w("#CompleteMenu1").onReady(() => {
let user = wixUsers.currentUser;
let isLoggedIn = user.loggedIn;
let userRole = user.role;
if (userRole === "Member") {
//$w("#Box1").hide();
user.getEmail()
.then((email) => {
let userEmail = email;
let thistestCode = $w("#CompleteMenu1").getCurrentItem().title_id;
return wixData.query('CLIENT')
.eq("Email_id", userEmail)
.eq("Test Code_id", thistestCode)
.descending("_createdDate")
.find();
})
.then((results) => {
if (results.totalCount) {
let items = results.items;
let firstItem = items[0];
$w("#txtPrice").text = firstItem.Price_id;
$w("#txtRemarks").text = "Pricing subject to change without notice unless a signed contract is in place.";
} else {
$w("#btnLogon").show();
$w("#txtPrice").text = "Sorry, no pricing available, please contact us";
}
})
.catch((err) => {
console.log(err);
});
}
});
});