- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 01-04-2019 10:56 AM
Create a script include and copy the below code
Script include Name: TableScript_Utils
Code:
var TableScript_Utils = Class.create();
TableScript_Utils.prototype = {
initialize: function(tableLabel, tableName, extendsto, columnjson) {
this.Label = tableLabel;
this.Name = tableName;
this.Moduleneeded = false;
this.TableExtends = extendsto;
this.ColumnsJSON = columnjson; // comma delimited list of column names. by default, the type of column would be "string". change it as per your requirement.
},
createTable: function(){
var tc = new GlideTableCreator(this.Name, this.Label);
var columnattrs = this.getColumns();
tc.setColumnAttributes(columnattrs);
if(typeof this.TableExtends != 'undefined')
tc.setExtends(this.TableExtends);
tc.update();
gs.sleep(10000); //wait for table to be updated.
},
getColumns: function(){
var attrs = new Packages.java.util.HashMap();
var arrcolumns = this.ColumnsJSON.split(',');
for(var clm = 0; clm < arrcolumns.length; clm++){
var ca = new GlideColumnAttributes(arrcolumns[clm]);
ca.setType("string");
ca.setUsePrefix(true); // this can be changed if you don't want to add "u_" prefix to the column
attrs.put(arrcolumns[clm], ca);
}
return attrs;
},
type: 'TableScript_Utils'
};
How to call this
var g = "name,age";
var m = new TableScript_Utils('My script table', 'my_script_table','sys_user', g);
m.createTable();
Hope this helps.
- 5,368 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
This does not work in Rome.
GlideTableCreator is not allowed in scoped applications
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
It works. Make sure you do these
Script Include changes
While you calling the script, use this code
Example
var g = "name,age";
var m = new global.TableScript_Utils('My script table', 'my_script_table','sys_user', g);
m.createTable();
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Works great thanks😃
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
Instead of keeping scope as Global, can we create tables within scoped app ?
By doing in this way , there are restrictions imposed in using external APIs