- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Building on the "Xplore GlideRecord Script" Tool post, the "Preview in Background Script" tool will open a new Background Script window and populate the script field with the template of code containing the list view's query:
The script will be populated 1/4 second after the Background Script window is opened in order to ensure the window has been opened properly.
All you need to do is create a new Context Menu record with the following details:
Table: Global
Menu: List Header
Type: Action
Name: Preview in Background Script
Order: 116,000
Condition: gs.hasRole("admin")
Action script:
(function u_previewGlideRecordScript(){
var fixedQuery = ("" + g_list.getFixedQuery()).replace("null", "");
if (fixedQuery == "") {
fixedQuery = ("" + g_list.getRelatedQuery()).replace("null", "");
}
var query = fixedQuery;
var listQuery = g_list.getQuery();
if (listQuery != "") {
if (query == "") {
query = listQuery;
} else {
query += "^" + listQuery;
}
}
var newLine = "\n";
var script = "(function() {" + newLine;
script += " var gr = new GlideRecord('" + g_list.tableName + "');" + newLine;
if (query != "") {
script += " gr.addEncodedQuery('" + query + "');" + newLine;
}
script += " //gr.setLimit(100);" + newLine;
script += " //gr.setWorkflow(false);" + newLine;
script += " //gr.autoSysFields(false);" + newLine;
script += " gr.query();" + newLine;
script += " while (gr.next()) {" + newLine;
script += " " + newLine;
script += " }" + newLine;
script += "})();";
// open the Background Scripts page in a new window
var win = window.open('/sys.scripts.do');
//and then populate the script box a quarter second later
setTimeout(function(){
try{
var textArea = win.document.getElementById("runscript");
textArea.value = script;
} catch(err){}
}, 250);
})();
Related posts:
- 1,549 Views
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
