Hi @swshrey, happy new year and sorry for the time it took me to answer.
I think what you’re trying to do is definitely possible, you could use custom code in the header of your page to hide the blocks you want with a querySelector, and then use another snippet in the footer to toggle the visibility of the specific one you want to display back on.
For that last part, I would advise to have a look at Artur’s solution here, since mine above has been impacted by some changes in the meantime and might not be fully functional anymore (especially the “data-mappedto” attribute used in the selector).
Let me know if you manage to work your way around that, if not happy to help !
@Julien_Berawen no probs at all and thanks v much for the reference. I think Artur’s solution MIGHT resolve a lot of user management issues that we currently have - will msg him and cc you - and if I need any help will get back to you, with huge thanks in advance in any event! I very much doubt if I can ever return the favour, unless you ever have to deal with data models relating to artworks, in which case I’m your man - if my tech colleagues ever need a softr coding resource, are you available on an hourly basis? If so, do let me know (didn’t see your name in the ‘Softr expert’ list…
Hello, all, I’m not a coder but this seems not to be working for me when I’m using a checkbox field and seeking a value of “true” so I’m assuming I’m missing something easy. If I just comment out the ‘if’ statement, it works.
The “markfinalbutton” is an action button in a form with hidden fields. The “marked_final” checkbox is displayed in a list details element.
document.addEventListener("DOMContentLoaded", function() {
var waitForData = setInterval(function () {
if (typeof $ != 'undefined') {
if (document.querySelectorAll('div[data-mappedto="marked_final"][data-value="true" i]').length > 0) {
var myForm = document.getElementById('markfinalbutton');
myForm.style.display = 'none';
clearInterval(waitForData);
}
}
}, 100);
});
@mb12142329 I think the data_mappedto attribute cannot be used anymore after some changes in the code structure. You’ll probably be better off using that solution.
Thank you but it’s still not working unfortunately. Here’s my version. Does it matter that it’s a linked field in Airtable? Should I be using a value other than “true”?
document.addEventListener(“DOMContentLoaded”, function() {
var waitForData = setInterval(function () {
if (typeof $ != ‘undefined’) {
const recordId = getUrlParam(‘recordId’);
if (window.records && window.records[recordId] && >
window.records[recordId].record.fields[‘markedfinal’] === ‘true’) {
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;
}
});
policy-edits:9 The key “target-densitydpi” is not supported.
micromodal.min.js:1 MicroModal: Please specify at least one ‘micromodal-trigger’ data attribute.
(anonymous) @ micromodal.min.js:1
micromodal.min.js:1 Example:
(anonymous) @ micromodal.min.js:1
policy-edits:1 Uncaught (in promise) Error: A listener indicated an asynchronous response by returning true, but the message channel closed before a response was received
Still the same unfortunately. To be clear, I’m putting this code in the footer. I’m not sure what else to try unless I’m just messing something up that’s very basic.
Yes, the footer should be the right place. Last thing I can think of : can you try individually testing each of the conditions using the browser console and let us know what comes out of each test ?
That would be successively :
Thanks, going to the console proved helpful because I realized (to my question earlier about checkboxes) that the value should be “checked” not “true”. It looks like there were two issues though because changing the value only worked when I simplified the IF statement and hardcoded the recordId. The other two functions seem unable to get the recordID for me. If I then go with the commented line below, it does not work. If I then put “window.records[recordId]” into the console, I get “Uncaught ReferenceError: recordId is not defined at :1:16”
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.
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.