Suppose you have a requirement that all saved Interactive Reports (IR) names must be lowercase. How can you enforce it? Using some JavaScript (JS) you can “intercept” the save and delete functions and either continue on with them or not. Note my uses case was very different than a naming standard but using it as an example as it’s very simple.
The following code snippet will intercept the save functionality (you can inject your business rules accordingly). It’s important to note that this code must be run in the page’s Function and Global Variable Declaration
section (as part of the page’s properties). A better alternative is to load it via a JS file (hint: use APEX Nitro). It will not work if you try to run it as is in your browser’s console.
Warning: The following code is using undocumented features in the APEX IR JS library. Use at your discretion.
1 | $(document).ready(function() { |
I’ve commented out return this._super();
. Re-enabling it will continue the function (save, remove, etc) as expected. In most cases you would wrap it in an if
condition based on your requirements.
The following demo shows this code in action. Both the save and delete requests don’t complete as the JS code intercepts the requests and logs some information.
