I'm trying to write a Lightning component for Items to approve section in Lightning home page, facing a issue in showing data in component, here under my controller and component codes.

Apex controller:

public class Lex_ItemsToApproveController{

public class item_wrapper {

       @AuraEnabled public String DateSubmited { get; set; }
       @AuraEnabled public id approvalid { get; set; }
       @AuraEnabled public id recordId {get;set;}
       @AuraEnabled public String CreatedByName {get;set;}
       @AuraEnabled public String recordName {get;set;}

        public item_wrapper( String DateSubmited,id approvalid, id recordId, String CreatedByName,String recordName ) {

            this.DateSubmited = DateSubmited;
            this.approvalid =approvalid ;
            this.recordId =recordId;
            this.CreatedByName =CreatedByName ;

Public static List<item_wrapper> getAllItemWrappers(){
    list<item_wrapper> items_to_approve = new List<item_wrapper>();
    map<id,processInstanceWorkItem>pwMap=new Map<id,processInstanceWorkItem>();
    list<processInstanceWorkItem>pwList=new List<processInstanceWorkItem>();

    List<Group>grpList=[select id, name, type from group where RelatedId =: userInfo.getUserRoleId()];
    List<ID>userorGroupid=new List<ID>();
    System.debug('grpList ==>'+grpList);

    for(Group item:grpList){

    Set<id> queueUserQueueIds=setOfIdFromListOfSObject([Select GroupId FROM GroupMember WHERE UserOrGroupId IN: userorGroupid], 'GroupId' );

    pwList=[SELECT  Id,OriginalActorId,OriginalActor.Name,ProcessInstance.TargetObject.Name,ProcessInstance.TargetObject.type, ActorId, CreatedById,
                                                     CreatedBy.id,CreatedBy.Name, ProcessInstance.TargetObjectId,Actor.Name,SystemModstamp,CreatedDate
                                               FROM ProcessInstanceWorkItem
                                              WHERE (ActorId in :queueUserQueueIds OR  actorid = :userinfo.getuserid())
                                                ORDER BY CreatedDate  DESC  LIMIT 1000];

    system.debug('pwList -->'+pwList.size());
        for(processInstanceWorkItem item:pwList){


        for(processInstanceWorkItem item:pwMap.values()){

            String sObjName = item.processinstance.targetobjectid.getSObjectType().getDescribe().getLabel();                
            String dateTimeValue = item.CreatedDate.format('MM/dd/yyyy hh:mm a');  

            items_to_approve.add(new item_wrapper(dateTimeValue,item.id,item.processInstance.targetObjectID,item.CreatedBy.Name,item.ProcessInstance.targetObject.name));

    system.debug('ItemsToAPprove size==>'+items_to_approve.size());
    system.debug('List size==>'+items_to_approve.size());
    system.debug('List 4==>'+items_to_approve);

    return items_to_approve;


     private static Set<Id> setOfIdFromListOfSObject( List<SObject> oList, String oName ) {
        Set<Id> Ids = new Set<Id> {};
        for (SObject o : oList) {
            Ids.add( String.valueof(o.get(oName)) );
        return Ids;

component :

<aura:component implements="flexipage:availableForAllPageTypes" access="global" controller="Lex_ItemsToApproveController">
      <aura:handler name="init" action="{!c.item_to_approve}" value="{!this}" />  
    <aura:attribute name="items_to_approve" type="List" />
            <aura:iteration items="{!v.items_to_approve}" var="item">



JS controller:


         item_to_approve  : function(component, event, helper) {
                helper.fetchItemsToApprove(component, event, helper);


Helper: ({ fetchItemsToApprove : function(component,Event,Helper) { var action = component.get("c.getAllItemWrappers");

      action.setCallback(this, function(response) {
        var state = response.getState();
        console.log('debug connsole state'+state);  
        if(state === 'SUCCESS') {
            var itemsToApprpove = response.getReturnValue();
            console.log('debug connsole1'+itemsToApprpove);
        else {
            alert('Error in getting data');


The error i'm getting is : This page has an error. You might just need to refresh it. Unable to find action 'items_to_approve' on the controller of c:LEX_ItemsToApproveComponent Failing descriptor: {c:LEX_ItemsToApproveComponent}

any help is appreciated to find the Issue, Thanks in advance.

2 Answers 2


Seems like you want to call an apex method from lightning front end controller. What you missing is the apex method, simply by having getter and setter you won't be able to get the information required to the front end. So in your apex controller have a method as follows,

public static List<item_wrapper> getAllItemWrappers() {
 //here you need to implement what you have done inside your constructor.
 // and return the item wrappers

Then in your front end lightning controller. Where you setup the action, do

var action = component.get("c.getAllItemWrappers"); 

instead of,

var action = component.get("c.items_to_approve"); 

You can't access a variable like this. That is a way to invoke an Apex method. Instead of doing everything in the constructor, create a @AuraEnabled method and move your code in that method. That method will return the wrapper object and you can set the component attribute with the returned result in the callback.

Check the following blog post for help -



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .