Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2024 10:32 PM
Hi Everyone,
I want to get names of all the fields present in table into array in scripted rest api.
Thanks in advance.
Solved! Go to Solution.
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 01:43 AM
Please try with below code, i checked on background script
var arr_fields=[];
var fields = new GlideRecord('sys_dictionary');
fields.addQuery('name','incident');
fields.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]);
}
Kindly mark helpful/accepted if it helps you.
Thanks
5 REPLIES 5
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2024 02:26 AM
@Abhijit Das7
Give a try to the code below.
var arr_fields = [];
var fields = new GlideRecord('sys_dictionary');
fields.addQuery('name', 'u_customer_details'); // Change 'incident' to 'u_customer_details'
fields.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 ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks,
Aniket