sysparm_fields in scripted REST API

Sagaya1
Giga Expert

Hi ,

I need to retrieve specific column from table instead of whole row from Gliderecord .  Have noticed it can be achievable through "sysparm_fields"  in table API . How can I do in Gliderecord . Please help.

 

find_real_file.png

 

Regards

Sagaya

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

specify your fields separated by comma

sysparm_field =  number,short_description,caller_id.name

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

14 REPLIES 14

Sukrit
Giga Contributor

Hi Sagaya

You can limit your query to specific fields in a server-side Glide query by using GlideAggregate instead of GlideRecord to query the table.

 

Thanks

Hi Sukrit,

Thank you for the details .GlideAggregate  is use for count /min/max operations . I need to retrieve specific columns of the record like sysparm_fields.

sysparm_fields Sample : sysparm_fields=dname%2Cu_aname%2Coccurdate_time%2C%2Ccleareddate_time

The above sysparm_fields will retrieve only 4 column [dname ,aname, occurdate_time and cleareddate_time]  instead of all column. GlideRecord will pull all column of the specific record .

 

find_real_file.png

Sagaya

Sukrit
Giga Contributor

Try using groupBy

var ga = new GlideAggregate('sys_user');
ga.groupBy('user_name');
ga.groupBy('sys_id'); // This makes sure we get all records, even if there are duplicates
ga.query();

while (ga.next()) {
  // Do what you need to with the user_name field
}

This would return 'user_name' and 'sys_id' fields.

Add another groupBy() for each field you need included in the results.

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

specify your fields separated by comma

sysparm_field =  number,short_description,caller_id.name

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader