The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get all field names of a table?

anchor
Kilo Contributor

How to get all field names of a table through server script?

1 ACCEPTED SOLUTION

Sagar Patro
Kilo Guru
var arr_fields=[];
var fields = new GlideRecord('sys_dictionary');
fields.addQuery('name','incident');

fileds.addEncodedQuery('internal_type!=collection^ORinternal_type=NULL');//To ignore all the table dictionaries(optional)

fields.query();

while(fields.next())
{
arr_fields.push(fields.column_label.toString()+"("+fields.element.toString() + ")" );
}


for(var i=0; i<arr_fields.length; i++)
{
   gs.print(arr_fields[i]);
}

 

Please mark ot helpful and correct if it was.

Regards!

View solution in original post

9 REPLIES 9

Mohammed Hyder1
Kilo Explorer

Try Select option..

Aakash Shah4
Tera Guru

Hi,

 

You can go to System Definition -> Dictionary.

Here you can type the table name and find all the related field names.

PFB image for reference:

find_real_file.png

Tushar Sharma2
Kilo Guru

Hello,

Try with below code on server script.

 

var fieldslist=[];
var fields = new GlideRecord('sys_dictionary');
fields.addQuery('name','incident'); // Write the table name for which you need field name list
fields.query();

while(fields.next())
{
fieldslist.push(fields.element.toString());
}


for(var i=0; i<fieldslist.length; i++)
{
   //get your field name using "fieldslist[i]"
}

 

Hit Like or Correct on the impact of response.

-Tushar

var arr_fields=[];
var fields = new GlideRecord('sys_dictionary');
fields.addQuery('name','incident');

fileds.addEncodedQuery('internal_type!=collection^ORinternal_type=NULL');//To ignore all the table dictionaries(optional)

fields.query();

while(fields.next())
{
arr_fields.push(fields.column_label.toString()+"("+fields.element.toString() + ")" );
}


for(var i=0; i<arr_fields.length; i++)
{
   gs.print(arr_fields[i]);
}

 

Please mark ot helpful and correct if it was.

Regards!