
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2016 05:16 PM
Is it possible to create a SN custom table via a script? I would like to create many tables that are coming from a different database. I would like to write a script to read in that ddl and then translate that to whatever SN needs to create these tables. It will save me a lot of typing. Thank you in advance.
Todd
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- 11,860 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 05:13 AM
Here's an example of adding a new extended table and a column
// create a new table 'abc' by extending 'task' and add new string column 'myfield'
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();
You can run this in Background Script and go to System Definition > Tables or Tables & Columns to see the new table and column.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-10-2017 10:21 AM
After create the table, did you change the glide.app.creator.global property to false. In other words, After creating the table, did you change the table scope to application scope instead of global scope?
Regards,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-17-2017 09:35 AM
I am able to finish this under application scoped script and now can create import set/staging tables from the script.
--Raj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 03:55 AM
Hi John,
is it possible to set to TRUE the flag "Extensible" of a table?
i'm trying to create a background script to create multiple extended table at time.
thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-26-2017 08:04 PM
Hi Mattia,
Yes, it's possible to set the "Extensible" flag to true for a table:
var gr = new GlideRecord('sys_db_object');
gr.query('name','mytable');
if (gr.next()) {
gs.info(gr.is_extendable);
gr.is_extendable = true;
gr.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2017 06:39 AM
Great! Thanks John!
where I can find all these information about the method and variable for GlideRecord? tipically I search in API reference on Developer site but "is_extendable" is not visible...
thank again