Skip to content

Dynamic Table Creation #1563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(function() {
var tableName = 'u_custom_table';
var tableLabel = 'Custom Table';
var tableDesc = 'Dynamically created table';
var tableSysId = GlideTableDescriptor.createTable(tableName, tableLabel, tableDesc);

var col1 = new GlideColumnDescriptor('u_name', tableSysId);
col1.setLabel('Name');
col1.setType('string');
col1.setMaxLength(100);
col1.create();

var col2 = new GlideColumnDescriptor('u_description', tableSysId);
col2.setLabel('Description');
col2.setType('string');
col2.setMaxLength(255);
col2.create();

gs.print("Table created with sys_id: " + tableSysId);
})();
1 change: 1 addition & 0 deletions Background Scripts/Dynamic Table Creation/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Normally, creating a new table means going through multiple steps in ServiceNow's interface. With this script, you can automate the process to quickly set up a new table with the exact columns you need. It’s useful when you need to frequently create similar tables, or you’re setting up a new application that requires multiple tables with specific fields.
Loading