Unable to hide buttons from the ui macro on the catalog task and request item table
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 02:06 PM
Hello, I created a catalog request that has a widget and ui Macro. The issue I am running into is I am unable to hide the buttons from the sc task and the ritm. This is the onload client script that I am using...
function onLoad() {
var currentTable = g_form.getTableName();
// Check if we are on the sc_task or sc_req_item table
if (currentTable === 'sc_task' || currentTable === 'sc_req_item') {
// Use setTimeout to ensure the DOM is fully loaded
setTimeout(function() {
// Select all buttons with class btn btn-primary
var buttons = document.querySelectorAll('button.btn.btn-primary');
console.log("Current Table: " + currentTable);
console.log("Buttons found: " + buttons.length);
// Hide the buttons
buttons.forEach(function(button) {
button.style.display = 'none';
});
// Confirm buttons are hidden
console.log("Buttons hidden.");
}, 1000); // Adjust timeout if needed
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-10-2024 06:10 PM
Hi @Rhonda9 ,
Please try this and see if it works.
function onLoad() {
var currentTable = g_form.getTableName();
if (currentTable === 'sc_task' || currentTable === 'sc_req_item') {
g_form.onLoad(function() {
var buttons = document.querySelectorAll('button.btn.btn-primary');
console.log("Current Table: " + currentTable);
console.log("Buttons found: " + buttons.length);
buttons.forEach(function(button) {
button.style.display = 'none';
});
console.log("Buttons hidden.");
});
}
}
Please mark my answer correct and helpful if this works for you.