- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 05:50 PM
I am working with the background script below learning how to create a table using script. It is working great.
Re: the GlideColumnAttributes class or method, I only saw sample code that used the following:
// Create general table settings
var table_name = 'u_a_test_table_creation_by_background_script',
extends_table = 'undefined';
//Set table attributes container
var tableAttributes = new Packages.java.util.HashMap();
//Add columns via function call
addColumn('ORG_CODE');
addColumn('L2_DESC');
addColumn('L3_DESC');
addColumn('STAFF_NBR');
addColumn('POSITION_NBR');
//Create table and push in all attributes both table and column
var tableCreator = new GlideTableCreator(table_name , table_name);
tableCreator.setColumnAttributes(tableAttributes);
if(typeof extends_table != 'undefined') tableCreator.setExtends(extends_table);
tableCreator.update();
function addColumn(columnName){
var columnAttributes = new GlideColumnAttributes(columnName);
columnAttributes.setType("string");
columnAttributes.setUsePrefix(false);
tableAttributes.put(columnName, columnAttributes);
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 02:55 AM
Unfortunately it is not documented.
But for your particular case you can use:
columnAttributes.setLength('100');
If you don't set a length a default one will be set automatically (40 for string).
On the other hand you can run the following script to see what methods are available:
var ca = new GlideColumnAttributes('incident');
for (var member in ca)
gs.print(member);
Gives me:
[0:00:00.003] Script completed in scope global: script
*** Script: getClass
*** Script: wait
*** Script: getLabel
*** Script: getName
*** Script: usePrefix
*** Script: notifyAll
*** Script: values
*** Script: setUsePrefix
*** Script: getColumnName
*** Script: type
*** Script: getReferenceTable
*** Script: notify
*** Script: setPrefixSysFields
*** Script: hashCode
*** Script: setUseOptimizedNameCleaner
*** Script: class
*** Script: addValue
*** Script: referenceTable
*** Script: prefixSysFields
*** Script: getValues
*** Script: length
*** Script: useOptimizedNameCleaner
*** Script: label
*** Script: setType
*** Script: intLength
*** Script: setReferenceTable
*** Script: isUseOptimizedNameCleaner
*** Script: setLength
*** Script: getType
*** Script: equals
*** Script: name
*** Script: getLength
*** Script: getIntLength
*** Script: setLabel
*** Script: DBName
*** Script: toString
*** Script: getDBName
*** Script: columnName
Regards,
Sergiu
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 02:55 AM
Unfortunately it is not documented.
But for your particular case you can use:
columnAttributes.setLength('100');
If you don't set a length a default one will be set automatically (40 for string).
On the other hand you can run the following script to see what methods are available:
var ca = new GlideColumnAttributes('incident');
for (var member in ca)
gs.print(member);
Gives me:
[0:00:00.003] Script completed in scope global: script
*** Script: getClass
*** Script: wait
*** Script: getLabel
*** Script: getName
*** Script: usePrefix
*** Script: notifyAll
*** Script: values
*** Script: setUsePrefix
*** Script: getColumnName
*** Script: type
*** Script: getReferenceTable
*** Script: notify
*** Script: setPrefixSysFields
*** Script: hashCode
*** Script: setUseOptimizedNameCleaner
*** Script: class
*** Script: addValue
*** Script: referenceTable
*** Script: prefixSysFields
*** Script: getValues
*** Script: length
*** Script: useOptimizedNameCleaner
*** Script: label
*** Script: setType
*** Script: intLength
*** Script: setReferenceTable
*** Script: isUseOptimizedNameCleaner
*** Script: setLength
*** Script: getType
*** Script: equals
*** Script: name
*** Script: getLength
*** Script: getIntLength
*** Script: setLabel
*** Script: DBName
*** Script: toString
*** Script: getDBName
*** Script: columnName
Regards,
Sergiu

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 03:49 AM
Hello Sergiu,
Just wanted to know the duration & resolution to get the below issue to be resolved:
Service Interruption: This instance is unavailable
since as per my understanding the above is observed when the instance is under scheduled maintenance.
-Hussain K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 03:59 AM
This post is not related to the initial question!
Where are you seeing that message: on which instance?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 09:58 AM
Thank you for your reply. I tried the .setLength option but it did not do anything. All fields are still set at 40 chars. For testing I hard coded the setLength to '10' ... it doesnt' seem to do anything. I tried integer 10 ...and it threw an error.
Again thank you for any help figuring this out.
ER
Here is the script:
// Create general table settings
var table_name = 'u_a_test_table_creation_by_background_script';
// , extends_table = 'undefined';
//Set table attributes container
var tableAttributes = new Packages.java.util.HashMap();
//Add columns via function call
addColumn('ORG_CODE');
addColumn('L2_DESC');
addColumn('L3_DESC');
addColumn('POSITION_NBR');
addColumn('TITLE');
//Create table and push in all attributes both table and column
var tableCreator = new GlideTableCreator(table_name , table_name);
tableCreator.setColumnAttributes(tableAttributes);
if(typeof extends_table != 'undefined') tableCreator.setExtends(extends_table);
tableCreator.update();
function addColumn(columnName){
var columnAttributes = new GlideColumnAttributes(columnName);
columnAttributes.setType("string");
columnAttributes.setUsePrefix(false);
columnAttributes.setLength('10');
tableAttributes.put(columnName, columnAttributes);
}