Is there a class definition somewhere for GlideColumnAttributes

ericroberts
Tera Contributor

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:

columnAttributes.setType("string");
columnAttributes.setUsePrefix(false);
 
Is there a place where all the other options are documented that I can use?  The main one I need is character length.  But it'd be nice to know what else I can set if at all possible.
 
Thanks,
 
ER
 
// 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);
}
1 ACCEPTED SOLUTION

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

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

 

View solution in original post

5 REPLIES 5

sergiu_panaite
ServiceNow Employee
ServiceNow Employee

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

 

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

This post is not related to the initial question! 

Where are you seeing that message: on which instance?

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);
}