This should work : window.records[Object.keys(records)[0]].recordId
(instead of window.records[recordId]
)
That’s it! Thank you. Here’s what’s working if others want to replicate.
document.addEventListener(‘DOMContentLoaded’, function() {
var waitForData = setInterval(function () {
if (typeof $ != ‘undefined’) {
const recordId = window.records[Object.keys(records)[0]].record.fields.MarkedFinal;
if (recordId === ‘checked’) {
var form1 = document.getElementById(‘markfinalbutton’);
form1.style.display = ‘none’;
clearInterval(waitForData);
}
}
}, 100);
function getUrlParam(name) {
const url = new URL(window.location.href);
let param;
for(var key of url.searchParams.keys()) {
if(key.toLowerCase() === name.toLowerCase()) {
param = url.searchParams.get(name);
break;
}
}
if(!param && name.toLowerCase() === ‘recordid’) {
param = getRecordIdFromPath();
}
return param;
}
function getRecordIdFromPath() {
let pathName = window.location.pathname;
if (pathName.indexOf(‘/r/rec’) !== -1) {
pathName = pathName.substr(pathName.indexOf(‘/r/rec’) + 3);
if (pathName.indexOf(“/”) !== -1) {
pathName = pathName(0, pathName.indexOf(‘/’))
}
return pathName;
}
return undefined;
}
});
You can even get rid of the getting the recordID from the URL part, since you’re getting it directly from the JS object.
document.addEventListener("DOMContentLoaded", function() {
var waitForData = setInterval(function () {
if (typeof $ != 'undefined') {
const isFinal = window.records[Object.keys(records)[0]].record.fields.MarkedFinal;
if (isFinal === 'checked') {
var buttonToHide = document.getElementById('markfinalbutton');
buttonToHide.style.display = 'none';
clearInterval(waitForData);
}
}
}, 100);
});
This error message indicates that there was a problem with the communication between the listener and the message channel. The listener sent a response indicating that it was ready to receive a message, but the message channel closed before the listener was able to receive the message.
In most cases the reason is that you call chrome.runtime.sendMessage when the popup is not shown. The popup cannot receive messages if it’s not shown. You can suppress the error by using ‘()=>chrome.runtime.lastError’ instead of ‘function(response){}’ .
Another possible solution would be show the popup in a new window using chrome.windows.create or as a DOM element inside the web page.
if (document.querySelectorAll(‘div[data-mappedto=“event_status”][data-value=“full” i]’).length > 0) {
–
Am I able to make data-value= a variable such as Logged-in User’s email?
I want it to basically check a field in the record and if the logged-in user’s email in that field, then don’t show it
Hi there!
I’d love to use this but I’m not sure I’m configuring correctly. First, I notice there is “bookingForm” – do I need to edit that parameter? I’m not sure what that is referring to in my set-up.
Also the data field I’m looking at is a roll-up for balance owing across invoices. I’ve tried “$0.00” and just “0” but the block still shows.
Any help would be appreciated!
Cheers,
Nicole
Hi! so I tried to use the code and according to support it doesn’t work anymore. So can you plase share the updated code for it. Thanks.