The CreatorCon Call for Content is officially open! Get started here.

getFields question

Yusuf5
Tera Expert

Hi,

I'm trying to get the fields for any table.

The following code snippet works for incident but not for pm_project.

Any help is appreciated.

var gr = new GlideRecord("incident");
gr.query();
var fields = gr.getFields();
gs.print(fields.size());

Regards

Yusuf

1 ACCEPTED SOLUTION

Yusuf5
Tera Expert

Hi all,

 

Somehow I need to do the next().

incident doesn't require but pm_project or some other tables do.

var gr = new GlideRecord("pm_project");
gr.query();gr.next(); //Works this time
var fields = gr.getFields();
gs.print(fields.size());

 

View solution in original post

4 REPLIES 4

georgimavrodiev
Mega Guru

Good Morning Yusuf,



Simply use the correct table's name and for the projects records.
If you are not familiar with the exact table -> then, open such record > check its table > use it in your GlideRecord query.



Best Regards,
Georgi Mavrodiev

IT Consultant 
Do IT Wise Bulgaria

You may visit us in our Web Site: www.doitwise.com

Swathi12
Tera Expert

Hi Yusuf,

 

I tried the below snippet :

 

var gr = new GlideRecord("pm_project");
gr.query();
var fields = gr.getFields();
gs.print(fields.size());

 

It returned me 

*** Script: 154

Or you can try the below code:

var gr = new GlideRecord('pm_project');
gr.query();
gr.next();

var gRU = new GlideRecordUtil();
var fieldList = gRU.getFields(gr);
gs.print(fieldList);

I got below answer :
*** Script: sys_id,parent,shadow,watch_list,phase_type,wbs,upon_reject,sys_updated_on,discount_rate,time_card_preference,rollup,approval_history,skills,score,number

Please do mark this helpful/correct if it answered your question.

Regards,
Swathi

Hi Swathi,

It is exactly same as my code snippet.

Unfortunately, it returns 0.

I am trying to find out the reason may be there is a SN parameter needs to be turned on or off.

Regards

Yusuf

Yusuf5
Tera Expert

Hi all,

 

Somehow I need to do the next().

incident doesn't require but pm_project or some other tables do.

var gr = new GlideRecord("pm_project");
gr.query();gr.next(); //Works this time
var fields = gr.getFields();
gs.print(fields.size());