
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 07-05-2019 03:27 AM
Hi,
I created a script that allows you to open the scripts include directly from the code.
To open the link, use ctrl + click.
This example is on Business rule table.
This is the final result:
This is the necessary script:
Client script on load, on Business rule table
function onLoad() {
try {
setTimeout(function(){
// Get all elements with class "cm-variable"
var scriptInclude = g_form.getFormElement().getElementsByClassName('cm-variable');
for(var i = 0; i < scriptInclude.length; i++) {
var fName = scriptInclude[i].innerHTML;
// Retrieve the Script include
var si = new GlideRecord("sys_script_include");
si.addQuery("name",fName);
si.setLimit(1);
si.query();
// Generate the link and update html
while(si.next()){
scriptInclude[i].innerHTML = '<a href="/nav_to.do?uri=sys_script_include.do?sys_id='+si.sys_id.toString()+'">'+fName+'</a>';
}
}
}, 3000);
} catch(exception) {
jslog('Error in Client Script <script>: ' + exception);
}
}
Notes
- Client script on load and not onChange, to avoid performance issue.
- Timeout of 3s necessary, because without it some times script field is loaded after the client script.
- Remember to press Ctrl before the click
I hope it's useful!
Corrections and comments are welcome 🙂
Daniele
- 1,449 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Very useful!
I wonder if you can avoid the scratchpad business rule, and remove the _blank target for the link, with the same result...

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Updated as suggested!
Many thanks Riccardo

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Nice, and wonderful one.

- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Stumbled on this looking for something else, but in case anybody else does in the future, this functionality is now provided ootb for all code editors - you just right-click the script include in your code > Open Definition:
Nice work to OP for coming up with this alternative, presumably before it was offered ootb - I've used the ootb feature a thousand times and it really is very valuable.