- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 09:55 AM
Our team is creating a widget that is using option schemas for Table and Fields. We are able to use split the field list so that it appears in an array, but we want the field name and field label in an object array.
This is our code so far:
var fieldArr = [];
data.field_list = [];
if(options && options.field_list)
fieldArr = options.field_list.split(',');
for(var i=0; i<fieldArr.length; i++){
data.field_list.push({
element: fieldArr[i],
label: ?
})
}
For Label, we've tried something like the below, but it obviously doesn't work.
label:fieldArr[i].getLabel()
Any ideas?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 11:26 AM
Give this a try. It looks like you can add the $sp.getField function to get the column label in your for loop.
for (i = 0; i < fieldArr.length; i++) {
var column = $sp.getField(new GlideRecord(options.table), fieldArr[i]).label;
data.field_list.push({
element: fieldArr[i],
label: column
})
}
console.log(data.field_list);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 11:26 AM
Give this a try. It looks like you can add the $sp.getField function to get the column label in your for loop.
for (i = 0; i < fieldArr.length; i++) {
var column = $sp.getField(new GlideRecord(options.table), fieldArr[i]).label;
data.field_list.push({
element: fieldArr[i],
label: column
})
}
console.log(data.field_list);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-27-2019 12:55 PM
Thanks