HTML
<template>
<lightning-combobox
name="recentReports"
label="Report"
placeholder="Select Report"
value={value}
options={reportOptions}
onchange={handleRecentReportsChange} >
</lightning-combobox>
</template>
JS
import { LightningElement, track, wire } from 'lwc';
import getRecentReports from '@salesforce/apex/ReportController.getRecentReports';
export default class ReportLink extends LightningElement {
@track reportOptions = [];
@track value = '';
connectedCallback() {
getRecentReports()
.then(result => {
for (var i = 0; i < result.length; i++) {
this.reportOptions.push({label: result[i].Name, value: result[i].Id});
alert(result[i].Name);
}
})
.catch(error => {
alert(JSON.stringify(error));
});
}
handleRecentReportsChange(){
}
}
Apex
public with sharing class ReportController {
public ReportController() {
}
@AuraEnabled(Cacheable=true)
public static List<RecentlyViewed> getRecentReports(){
return [SELECT Id, Name FROM RecentlyViewed WHERE Type = 'Report'];
}
}