- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:52 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 03:09 AM
We can create UI action and can use below scrip.
Source table is Assessment Metric
Var cat_sys_id = current.sys_id.toString();
var attrs = new Packages.java.util.HashMap();
var table_name= 'custom_table';
var fname;
var src_table = new GlideRecord('asmt_metric');
src_table.addQuery('category', cat_sys_id);
src_table.query();
while(src_table.next())
{
fname = src_table.name;
var ca = new GlideColumnAttributes(fname);
ca.setType("string");
ca.setUsePrefix(true);
attrs.put(fname, ca);
}
var tc = new GlideTableCreator(table_name , table_name);
tc.setColumnAttributes(attrs);
if(typeof extends_table != 'undefined') tc.setExtends(extends_table);
tc.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:54 AM
Hi Rajan,
This link have steps to create a custom table from script.
Can I create a custom table via a script?
Hope this helps you

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:55 AM
Hello Rajan,
Refer the below links may helpful to you.
Can I create a custom table via a script?
- var table_name = 'abc', extends_table = 'task', fname = 'myfield';
- var attrs = new Packages.java.util.HashMap();
- var ca = new GlideColumnAttributes(fname);
- ca.setType("string");
- ca.setUsePrefix(false);
- attrs.put(fname, ca);
- var tc = new GlideTableCreator(table_name , table_name);
- tc.setColumnAttributes(attrs);
- if(typeof extends_table != 'undefined') tc.setExtends(extends_table);
- tc.update();
How to automatically create a target table for a data import set?
ServiceNow Commnunity MVP -2018 class.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:57 AM
Hi Rajan,
Yes, we can create a table by using script.
Please explain your requirement in detail.
Regards,
Navdeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-11-2017 02:59 AM
Hi Navdeep,
The requirement is columns of this table will be the records in other tables.
Mraj