Thanks, I’ve had a look at the documentation, the link is a URL type and is a URL field in a database.
Here’s the pages code in onReady:
$w.onReady(function () {
$w("#dynamicDataset").onReady(() => {
console.log("Product data ready");
checkContent();
$w("#imgProduct").fitMode = "fixedWidth";
console.log("pdf link = " + $w("#dynamicDataset").getCurrentItem().specProductPdf);
console.log("app link = " + $w("#dynamicDataset").getCurrentItem().appLink);
console.log("bim link = " + $w("#dynamicDataset").getCurrentItem().bimLink);
let datasheet = $w("#dynamicDataset").getCurrentItem().specProductPdf;
if (datasheet === undefined || datasheet === "undefined" || datasheet === null || datasheet === "") {
console.log("datasheet null");
} else {
// datasheet.toString();
$w('#viewDatasheetButton').link = datasheet;
$w('#viewDatasheetButton').target = "_blank";
console.log("datasheet");
console.log($w('#viewDatasheetButton').link);
console.log($w('#viewDatasheetButton').target);
}
let app = $w("#dynamicDataset").getCurrentItem().appLink;
if (app === undefined || app === "undefined" || app === null || app === "") {
console.log("app null");
} else {
// app.toString();
$w('#viewAppButton').link = app;
$w('#viewAppButton').target = "_blank";
console.log("app");
console.log($w('#viewAppButton').link);
console.log($w('#viewAppButton').target);
}
let bim = $w("#dynamicDataset").getCurrentItem().bimLink;
if (bim === undefined || bim === "undefined" || bim === null || bim === "") {
console.log("bim null");
} else {
// bim.toString();
$w('#viewBimFileButton').link = bim;
$w('#viewBimFileButton').target = "_blank";
console.log("bim");
console.log($w('#viewBimFileButton').link);
console.log($w('#viewBimFileButton').target);
}
});
});
And here’s the onClick:
export async function viewDatasheetButton_click(event) {
let isAdminLocal = local.getItem("isAdmin");
let isAdminSession = session.getItem("isAdmin");
let isAdminMemory = memory.getItem("isAdmin");
if (isAdminLocal === "true" || isAdminSession === "true" || isAdminMemory === "true") {
console.log("*clicked*");
console.log("************************************** admin activity - hidden from analytics - proceeding **************************************")
wixLocation.to($w("#dynamicDataset").getCurrentItem().specProductPdf);
} else {
console.log("*clicked*");
let userId = wixUsers.currentUser.id;
let client = $w('#dynamicDataset').getCurrentItem().title;
let focus = $w('#dynamicDataset').getCurrentItem().specProduct;
let specificationEmailed = false;
let datasheet = true;
let product = $w("#dynamicDataset").getCurrentItem().specProduct;
let bim = false;
let app = false;
let impression = false;
let engagement = false;
let click = false;
let advert = false;
let course = false;
let sample = false;
let search = false;
let itemId = $w('#dynamicDataset').getCurrentItem()._id;
let itemOwner = $w('#dynamicDataset').getCurrentItem()._owner;
let permissionCode = $w('#dynamicDataset').getCurrentItem().collectionId;
await submit(userId, client, focus, impression, engagement, click, advert, product, course, search, itemId, itemOwner, specificationEmailed, datasheet, bim, app, permissionCode, sample)
.then((result) => {
console.log("Success = " + result);
wixLocation.to($w("#dynamicDataset").getCurrentItem().specProductPdf);
})
.catch((error) => {
let errorLocation = event.target.id;
let errorDetails = {
"userInformation": {
"email": $w('#txtTrackingUsrEmail').text,
"name": $w('#txtTrackingUsrCurrent').text,
"firstName": $w('#txtTrackingUsrFName').text,
"lastName": $w('#txtTrackingUsrLName').text,
"phone": $w('#txtTrackingUsrPhoneNumber').text,
},
"userLocation": {
"trackingStatus": $w('#txtTrackingUsrStatus').text,
"userLatitude": $w('#txtTrackingUsrLat').text,
"userLongitude": $w('#txtTrackingUsrLon').text,
"userContinent": $w('#txtTrackingUsrContinent').text,
"userCountryCode": $w('#txtTrackingUsrCountryCode').text,
"userCountry": $w('#txtTrackingUsrCountry').text,
"userRegion": $w('#txtTrackingUsrRegion').text,
"userCity": $w('#txtTrackingUsrCity').text,
"userIpAddress": $w('#txtTrackingUsrIP').text,
"userIpName": $w('#txtTrackingUsrIpName').text,
"userIpType": $w('#txtTrackingUsrIpType').text,
"userIsp": $w('#txtTrackingUsrIsp').text,
"userFormFactor": $w('#txtTrackingUsrFormFactor').text,
"userOrg": $w('#txtTrackingUsrOrg').text,
},
"pageLocation": {
"baseUrl": wixLocation.baseUrl,
"path": wixLocation.path,
"prefix": wixLocation.prefix,
"protocol": wixLocation.protocol,
"query": wixLocation.query,
"queryParams": wixLocation.queryParams,
"url": wixLocation.url
}
}
let errorMessage = error.message;
let errorCode = error.code;
errorLogging(errorMessage, errorCode, errorDetails, errorLocation)
});
$w('#analyticsProducts').setFieldValue("migratedToAnalytics", true);
$w('#analyticsProducts').setFieldValue("manufacturerViewed", $w('#dynamicDataset').getCurrentItem().title);
$w('#analyticsProducts').setFieldValue("productViewed", $w('#dynamicDataset').getCurrentItem().specProduct);
$w('#analyticsProducts').setFieldValue("comment", "Viewed the datasheet link for " + $w('#dynamicDataset').getCurrentItem().specProduct + " by " + $w('#dynamicDataset').getCurrentItem().title + " to " + $w('#txtTrackingUsrCurrent').text + "using email: " + $w('#txtTrackingUsrEmail').text);
$w('#analyticsProducts').setFieldValue("productOwner", $w('#dynamicDataset').getCurrentItem()._owner);
$w('#analyticsProducts').setFieldValue("productId", $w('#dynamicDataset').getCurrentItem()._id);
$w('#analyticsProducts').setFieldValue("collectionId", $w('#dynamicDataset').getCurrentItem().collectionId);
// user details
$w('#analyticsProducts').setFieldValue("email", $w('#txtTrackingUsrEmail').text);
$w('#analyticsProducts').setFieldValue("fullName", $w('#txtTrackingUsrCurrent').text);
$w('#analyticsProducts').setFieldValue("firstName", $w('#txtTrackingUsrFName').text);
$w('#analyticsProducts').setFieldValue("lastName", $w('#txtTrackingUsrLName').text);
$w('#analyticsProducts').setFieldValue("contactNo", $w('#txtTrackingUsrPhoneNumber').text);
// user physical location
$w('#analyticsProducts').setFieldValue("country", $w('#txtTrackingUsrCountry').text);
$w('#analyticsProducts').setFieldValue("province", $w('#txtTrackingUsrRegion').text);
$w('#analyticsProducts').setFieldValue("city", $w('#txtTrackingUsrCity').text);
// data save
$w("#analyticsProducts").save()
.catch((error) => {
let errorLocation = (event.target.id + " - " + error);
let errorDetails = {
"userInformation": {
"email": $w('#txtTrackingUsrEmail').text,
"name": $w('#txtTrackingUsrCurrent').text,
"firstName": $w('#txtTrackingUsrFName').text,
"lastName": $w('#txtTrackingUsrLName').text,
"phone": $w('#txtTrackingUsrPhoneNumber').text,
},
"userLocation": {
"trackingStatus": $w('#txtTrackingUsrStatus').text,
"userLatitude": $w('#txtTrackingUsrLat').text,
"userLongitude": $w('#txtTrackingUsrLon').text,
"userContinent": $w('#txtTrackingUsrContinent').text,
"userCountryCode": $w('#txtTrackingUsrCountryCode').text,
"userCountry": $w('#txtTrackingUsrCountry').text,
"userRegion": $w('#txtTrackingUsrRegion').text,
"userCity": $w('#txtTrackingUsrCity').text,
"userIpAddress": $w('#txtTrackingUsrIP').text,
"userIpName": $w('#txtTrackingUsrIpName').text,
"userIpType": $w('#txtTrackingUsrIpType').text,
"userIsp": $w('#txtTrackingUsrIsp').text,
"userFormFactor": $w('#txtTrackingUsrFormFactor').text,
"userOrg": $w('#txtTrackingUsrOrg').text,
},
"pageLocation": {
"baseUrl": wixLocation.baseUrl,
"path": wixLocation.path,
"prefix": wixLocation.prefix,
"protocol": wixLocation.protocol,
"query": wixLocation.query,
"queryParams": wixLocation.queryParams,
"url": wixLocation.url
}
}
let errorMessage = error.message;
let errorCode = error.code;
errorLogging(errorMessage, errorCode, errorDetails, errorLocation)
});
}
}
page link: https://editor.wix.com/html/editor/web/renderer/edit/ab9e2d9a-adb7-4a5f-b604-12c2a9745474?metaSiteId=a804e724-2fc4-4d2b-ab68-d879299803bf&editorSessionId=37d6f4b0-c03e-4c00-8096-1e935d7337f3&referralInfo=dashboard