This question has a couple of fundamental aspects I would like to cover:
Bad design
The fact that you have to hide "Delete" button tells me that you Archer application is not designed right. You need to control access to the records via roles and records permission configuration, but not with Custom Object code.
What if I activate the Delete button manually using the developer tools and will delete the record? Do you want to be responsible for this as a developer?
I recommend you to make two steps back and redesign access controls in your application. The question you asked should be me asked at first place.
RSA Archer Platform
All jQuery related answers don't account for the following factors:
- This is a code for the Custom Object - special type of object used in RSA Archer platform.
- Archer platform generates JavaScript-rich web-pages. So I recommend you not to overload document related functions unless there is a real need to do so.
- Custom object code is executed when the form is loaded, in the most cases there is no need to override "document.load" event handler.
This is an example of code you can use for IE8-IE11, FireFox, Chrome and Opera:
<script type="text/javascript">
document.getElementById("master_btnDelete").style.display = "none";
</script>
Why this works? Because JavaScript code stored in the Custom Objects in Archer will be executed once it is loaded as a part of the form itself.
IE Specific Behavior
You actually may need to override window load event in case if the given archer application has a pop-up dialog windows used to populate value lists of cross-references. In this case tool bar buttons including "Delete" button might be restored after each pop-up window being displayed. In this case you have to use a similar code:
<script type="text/javascript">
// function that will hide the Delete button
function doLoad() {
alert( "The load event is executing" );
document.getElementById("master_btnDelete").style.display = "none";
}
// code that will add load event for IE and none-IE browsers
if (window.addEventListener){window.addEventListener("load",doLoad,false);}
else
if (window.attachEvent) { window.attachEvent("onload",doLoad);}
else
if (window.onLoad) { window.onload = doLoad;}
</script>
Unfortunately Microsoft was not very consistent with IE design, this is why you have to check what event handling method works and should be used.
You can use the following two links as a reference if you have more questions on this code:StackoverFlow Question and MSDN Help Page
Now, why your jQuery bases code didn't work? I don't know, could be that the Archer version you code for used a version of jQuery library that doesn't support IE9 well enough. And this brings me to another point.
Usage of the jQuery supplied with Archer
You used jQuery in the original code sample provided. I recommend you not to use any libraries when you write custom objects for Archer.
- jQuery library you used was provided as a part of the platform. jQuery library can be "custom build" to include the functions you use. Or in this case, to include the jQuery functions Archer developers used. In the next version of Archer this list may get changed. What happens if the functions you used are no longer a part of the library in the latest versions?
- You don't have a control over jQuery version used. So you can't guarantee the support for certain browsers and you can't force RSA to use latest version. This limits the functionality of your code. And this is exactly what happened here. You used jQuery and it didn't work with IE9. Will it work with IE11? And what happens after you upgrade Archer with latest patch?
- Keep in mind that the code you write will has to work with another 10k+ lines of JavaScript code loaded with page by Archer already. So keep your custom object as simple as possible and try not to use any external libraries. It is all about support (unless you are there for 1 months and don't plan to support your code).
Summary
- Don't hide Delete buttons in RSA Archer, but redesign the security.You will regret the decision of hiding Delete button in a long run. One day user will actually delete the record and you will feel the pain.
- Use KISS principle - use simple JavaScript code, avoid libraries, keep Custom objects short. Avoid custom object whenever possible. Or you will have to test them every time you update the platform.
Good luck, user3728843!