Currently unmaintained since I have moved from Microfocus Service Manager to ServiceNow - Sorry guys!
- Installation
- Supported Databases
- Make a table
- Update a table
- Available Fields
- Available Keys
- Todos
- Fields
- Modify Methods
- Field Options
- Keys
- Helpers
- Examples
- Credits
Just create a new ScriptLibrary for each file and copy the file content inside the new created ScriptLibrary. Currently there is no plan to deliver a unload file.
- MSSQL - tested with SM 9.52 and SM9.60
- Postgres - tested with ITSMA ( SM9.52 )
To create a new dbdict table, you have to use the make
method.
var tableBuilder = system.library.tableBuilder.getClass();
var schema = new tableBuilder();
schema.make('complextable', function(builder) {
/**
* Allowed methods are:
* * all methods to add a field
* * all methods to add a key
*/
});
To update a existing dbdict table, you have to use the modify
method.
var tableBuilder = system.library.tableBuilder.getClass();
var schema = new tableBuilder();
schema.modify('complextable', function(builder) {
/**
* Allowed methods are:
* * all methods to add a field
* * all methods to add a key
* * rename a field
*/
});
Type | SM Type |
---|---|
Number | 1 |
Character | 2 |
Date/Time | 3 |
Logical | 4 |
Array | 8 |
Structure | 9 |
Expression | 11 |
- Unique
- Primary
- No Nulls
- No Duplicates
- Nulls & Duplicates
- [] more documentation for each field
- [] Add more options
builder.addNumber('fieldname');
builder.addCharacter('fieldname');
builder.addDatetime('fieldname');
builder.addLogical('fieldname');
builder.addArray('fieldname', function(item) {
//all field types are allowed
});
builder.addArrayOfNumber('fieldname');
builder.addArrayOfCharacter('fieldname');
builder.addArrayOfDatetime('fieldname');
builder.addArrayOfLogical('fieldname');
builder.addStructure("filter", function(item) {
item.addCharacter("filter.sql");
});
builder.addExpression('fieldname');
Currently, the rename works only for simple fields (number
, character
, date/time
, logical
).
Rename the field, but keep the SQL Name
builder.renameField('is_active', 'isActive');
Rename the field and update the SQL Name.
builder.renameField('is_active', 'isActive', true);
Updates the sql length of a field.
The method uses the information from the sqldbinfo
table to determines if the current field has the Get Size
option.
builder.setLength('brief.description', 500);
For common fields, you can change field SQL Type.
builder.addCharacter("textfield").setSqlType("NVARCHAR(100)");
Overwrites the default sql field name with the defined value.
builder.addCharacter("textfield").setSqlName("AWESOMETEXTFIELD");
If you want, you can move a field to another table alias (e.g. from M1 to M2).
❗ All following fields will be attached to
M2
. If you want only one field in a new table, add the field at the end of your definition or add.setSqlTable("M1")
to the next field.This is an HPSM problem - I have tested it with the dbdidct utilities and the result was the same!
builder.addCharacter("textfield").setSqlTable("M2");
builder.addUniqueKey(['fieldname']);
builder.addPrimaryKey(['fieldname']);
builder.addNoNullKey(['fieldname']);
builder.addNoDuplicateKey(['fieldname']);
builder.addNullDuplicateKey(['fieldname']);
Instead of
builder.addCharacter('sysmoduser');
builder.addDatetime('sysmodtime');
builder.addNumber('sysmodcount');
in your definition, you can use this:
builder.withSysmodFields();
var tableBuilder = system.library.tableBuilder.getClass();
var schema = new tableBuilder();
schema.make('simpletable', function(builder) {
builder.addNumber('id');
builder.addLogical('is_active');
builder.addCharacter('sysmoduser');
builder.addDatetime('sysmodtime');
builder.addNumber('sysmodcount');
builder.addUniqueKey(['id']);
});
Expected result after running the code:
You should see a new entry in your Messages
with something like:
Table simpletable has been created successfully.
var tableBuilder = system.library.tableBuilder.getClass();
var schema = new tableBuilder();
schema.make('complextable', function(builder) {
builder.addNumber('id');
builder.addLogical('is_active');
builder.addCharacter('brief.description');
builder.addArray("longdescription", function(item) {
item.addCharacter("longdescription");
});
builder.addStructure("filter", function(item) {
item.addCharacter("filter.sql");
});
builder.addArray("rule", function(item) {
item.addStructure("rule", function(subitem) {
subitem.addNumber("ruleId");
});
});
builder.withSysmodFields();
builder.addUniqueKey(['id']);
});
var tableBuilder = system.library.tableBuilder.getClass();
var schema = new tableBuilder();
schema.modify('complextable', function(builder) {
//add a new field to the existing table
builder.addNumber('reference.id');
builder.renameField('is_active', 'isActive', true);
builder.setLength('brief.description', 500);
});
Expected result after running the code:
You should see a new entry in your Messages
with something like:
Table complextable has been created successfully.
Special thanks goes to: