+ Start a Discussion
Viru D.Viru D. 

Quick action component is not showing anything

my component is working fine independently when tested in lightning app but dosen't show anything when loaded from Quick action button. Plase suggest if any changes are required in code. Thanks in advance.

Works fine here :-
<aura:application extends="force:slds">
    <c:Sample_Req_Line_Comp />
    <!--<c:TestingComp1 />-->
</aura:application>

Not working on Quick action button :-

User-added image








Code snipet :-

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
    <aura:attribute name="isError" type="Boolean" default="false"/>

     
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      checking here ==> {!v.isError}

      <aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>
      
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product Family</label>
       <div class="slds-form-element__control"> 
    <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedFamily}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
        <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
        </aura:iteration>
    </lightning:select>
    </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product</label>
       <div class="slds-form-element__control"> 
       <lightning:select name="myproduct" label="" aura:id="mySelect2" value="{!v.selectedProduct}" onchange="{!c.onPicklistChange2}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist">
       <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options2}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
         </aura:iteration>
        </lightning:select>
      </div>
    </div>     
    
        
        
     <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Inventory Name</label>
      <div class="slds-form-element__control">
         <force:outputField value="{!v.InventoryRecord.Name}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Available</label>
      <div class="slds-form-element__control">
        <!--<force:outputField value="{!v.InventoryRecord.Quantity_Available__c}" />-->
        <lightning:formattedNumber value="{!v.InventoryRecord.Quantity_Available__c}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Sample Hub</label>
      <div class="slds-form-element__control">
        
      </div>
    </div>
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Requested</label>
      <div class="slds-form-element__control">
          <lightning:input type="number" aura:id="Req_qty" label=""
                             name="expenseamount"
                             min="1"
                             formatter="decimal"
                             step="1"
                             value="{!V.Request_Qty}"
                             messageWhenRangeUnderflow="Enter Quantity"/>
      </div>
    </div>
    
      
   <lightning:button label="Save" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.SaveData}"/>   
    
    
    <!--<force:outputField value="{!v.InventoryRecord.Sample_Hub__r.name}" />-->
    <!--<force:inputField value="{!v.InventoryRecord.Name}"/>-->
    <!--<lightning:formattedText value="I like salesforce.com and trailhead.salesforce.com." />-->
  
    </div>    

    <!--
    <lightning:recordViewForm recordId="{!v.InventoryRecord}" objectApiName="Sample_Inventory__c" >
        <div class="slds-box slds-theme_default">
            <lightning:outputField fieldName="name" />
            <lightning:outputField fieldName="Quantity_Available__c" />
            <lightning:outputField fieldName="Sample_Hub__r.name"/>
        </div>
    </lightning:recordViewForm>
    -->
</aura:component>

 
Raj VakatiRaj Vakati
Can you share the complete code? Including javascript controller and apex controller  
Viru D.Viru D.
Component Markup: Consider below latest markup and not older one.

<aura:component controller="Sample_Req_Line_Comp_CLS" implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickActionWithoutHeader" access="global" >

    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="options" type="List" />
    <aura:attribute name="options2" type="List" />
    <aura:attribute name="SelectedFamily" type="String" default="Red"/>
    <aura:attribute name="selectedProduct" type="String" default="Red"/>
    <aura:attribute name="InventoryRecord" type="Sample_Inventory__c" default="{sobjectType: 'Sample_Inventory__c',name : 'akshfdkjdsahf'}" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="Request_Qty" type="Integer" />
    <aura:attribute name="recordError" type="String" access="private"/>
    <aura:attribute name="isError" type="Boolean" default="false"/>

     
  <div class="slds-m-left_x-large" >
    <lightning:layout class="slds-page-header slds-page-header--object-home">
        <lightning:layoutItem >
            <lightning:icon iconName="standard:orders" alternativeText="My Expenses"/>
        </lightning:layoutItem>
        <lightning:layoutItem padding="horizontal-small">
            <div class="page-section page-header">
                <h1 class="slds-text-heading--label">Sample Request Line</h1>
                <h2 class="slds-text-heading--medium">Order Samples</h2>
            </div>
        </lightning:layoutItem>
    </lightning:layout>

      

      <aura:if isTrue="{!v.isError}"> 
        <ui:message title="Error" severity="error" closable="true" class="slds-form-element slds-size_2-of-12 slds-m-bottom_medium">
         <b>  {!v.recordError} </b> 
      </ui:message>         
     </aura:if>
      
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product Family</label>
       <div class="slds-form-element__control"> 
    <lightning:select name="mySelect" label=""  aura:id="mySelect" value="{!v.SelectedFamily}" onchange="{!c.onPicklistChange}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist" >
        <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
        </aura:iteration>
    </lightning:select>
    </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
    <label class="slds-form-element__label" for="input-unique-id">Select Product</label>
       <div class="slds-form-element__control"> 
       <lightning:select name="myproduct" label="" aura:id="mySelect2" value="{!v.selectedProduct}" onchange="{!c.onPicklistChange2}" class="slds-combobox slds-dropdown-trigger slds-dropdown-trigger_click slds-combobox-picklist">
       <option text="--Select--" value="--Select--" selected="--Select--"/>
        <aura:iteration items="{!v.options2}" var="item">
            <option text="{!item.label}" value="{!item.value}" selected="{!item.selected}"/>
         </aura:iteration>
        </lightning:select>
      </div>
    </div>     
    
        
        
     <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Inventory Name</label>
      <div class="slds-form-element__control">
         <force:outputField value="{!v.InventoryRecord.Name}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Available</label>
      <div class="slds-form-element__control">
        <!--<force:outputField value="{!v.InventoryRecord.Quantity_Available__c}" />-->
        <lightning:formattedNumber value="{!v.InventoryRecord.Quantity_Available__c}" />
      </div>
    </div>
    
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Sample Hub</label>
      <div class="slds-form-element__control">
        
      </div>
    </div>
    
    <div class="slds-form-element slds-size_1-of-12 slds-m-bottom_medium">
      <label class="slds-form-element__label" for="input-unique-id">Quantity Requested</label>
      <div class="slds-form-element__control">
          <lightning:input type="number" aura:id="Req_qty" label=""
                             name="expenseamount"
                             min="1"
                             formatter="decimal"
                             step="1"
                             value="{!V.Request_Qty}"
                             messageWhenRangeUnderflow="Enter Quantity"/>
      </div>
    </div>
    
      
   <lightning:button label="Save" 
                              class="slds-m-top--medium"
                              variant="brand"
                              onclick="{!c.SaveData}"/>   
    
    
    <!--<force:outputField value="{!v.InventoryRecord.Sample_Hub__r.name}" />-->
    <!--<force:inputField value="{!v.InventoryRecord.Name}"/>-->
    <!--<lightning:formattedText value="I like salesforce.com and trailhead.salesforce.com." />-->
  
    </div>    

    <!--
    <lightning:recordViewForm recordId="{!v.InventoryRecord}" objectApiName="Sample_Inventory__c" >
        <div class="slds-box slds-theme_default">
            <lightning:outputField fieldName="name" />
            <lightning:outputField fieldName="Quantity_Available__c" />
            <lightning:outputField fieldName="Sample_Hub__r.name"/>
        </div>
    </lightning:recordViewForm>
    -->
</aura:component>


Controller :

({
     doInit : function(component, event, helper) {
        helper.getFamilies(component);
    },
    
    onPicklistChange: function(component, event, helper) {
        // get the value of select option
        //alert(event.getSource().get("v.value"));
        var strtype1 = event.getSource().get("v.value")
        console.log('==strtype1==' + strtype1); 
        helper.fetchProducts(component, event, helper, strtype1);
    },
    
    onPicklistChange2: function(component, event, helper) {
        // get the value of select option
        var selectedProduct = event.getSource().get("v.value")
        console.log('==in Controlller==selectedProduct==' + selectedProduct);
        helper.FetchInventory(component, event, helper, selectedProduct);
        
    },
    
      SaveData: function(component, event, helper) {
        // get the value of select option
       var ReqQty = component.get("v.Request_Qty");
       var recordId = component.get("v.recordId");
       var selectedProduct = component.get("v.selectedProduct");   
          
        helper.SaveData_Ctrl(component, event, helper, ReqQty,selectedProduct,recordId);
        
    }

    
})


Helper :-
({
    getFamilies : function(component) {
        
        var action = component.get("c.getProductFamilies");
        var opts = [];
        //Setting the Callback
            action.setCallback(this,function(response){
                //get the response state
                var state = response.getState();
                
                //check if result is successfull
                if(state == "SUCCESS"){
                   var allValues = response.getReturnValue();
                  for (var i = 0; i < allValues.length; i++) {
                    opts.push({
                        class: "optionClass", 
                        label: allValues[i],
                        value: allValues[i]
                    });
                }
                component.set("v.options", opts);
                
  
                } else if(state == "ERROR"){
                    alert('Error in calling server side action');
                }
            });
            
            //adds the server-side action to the queue        
            $A.enqueueAction(action);
    },
    
     fetchProducts: function(component, event, helper, strtype2) {
        console.log('==Helper : strtype2==' +  strtype2);
        var action = component.get("c.FetchProducts");
        action.setParams({
            "selected_family": strtype2
        });
        var opts = [];
        action.setCallback(this, function(response) {
            if (response.getState() == "SUCCESS") {
                var allValues = response.getReturnValue();
               for (var i = 0; i < allValues.length; i++) {
                   opts.push({
                       class: "optionClass",
                       label: allValues[i],
                        value: allValues[i]
                    });
                }
                component.set("v.options2", opts);
            }
        });
        $A.enqueueAction(action);
    },
    
     FetchInventory: function(component, event, helper, strtype2) {
        console.log('==Helper : strtype2==' +  strtype2);
        var action = component.get("c.FetchInventory");
        action.setParams({
            "selectedProduct": strtype2
        });
         var opts = [];
        action.setCallback(this, function(response) {
            if (response.getState() == "SUCCESS") {
                component.set("v.InventoryRecord", response.getReturnValue());
            }
        });
         
         
        $A.enqueueAction(action);
    },
    
    SaveData_Ctrl: function(component, event, helper, ReqQty,selectedProduct,SampleReq_id) {
        var action = component.get("c.SaveData2");
        action.setParams({
            "Requested_Qty": ReqQty,
            "selectedProduct": selectedProduct,
            "SampleReq_id": SampleReq_id
        });
        action.setCallback(this, function(response) {
            if (response.getState() === "SUCCESS") {
                var showerror = false; 
                component.set("v.isError", showerror);
                component.set("v.InventoryRecord", response.getReturnValue());
                console.log('==Success isError==' + component.get("v.isError"));
            }
            else{
                var errors = action.getError();
                var showerror2 = true;
                component.set("v.isError", showerror2);
                component.set("v.recordError", errors[0].message);
                console.log('==checking isError==' + component.get("v.isError"));
                
           }
        });
        $A.enqueueAction(action);
    },
    
})

sharing apex controller in next post.

 
 
Viru D.Viru D.
Apex Controller :

public class Sample_Req_Line_Comp_CLS {
static string Distributor_Name;
static map<string,Sample_Book__c> MapSamplebook = new map<string,Sample_Book__c>();    
    public Sample_Req_Line_Comp_CLS(){
    }
    
     @AuraEnabled
    public static List<string> getProductFamilies() {
        List<string> lstFamilies = new List<string>(); 
        set<string> Family_set = New set<string>();    
        
        Distributor_Name = getDistributor_Name();
        system.debug('==Distributor_Name==' + Distributor_Name);
        
        if(Distributor_Name != null)
        {//Sample book is defined for an account or Reporting parent account.
            List<Sample_Book__c> ListSampleBook = getSampleBook(Distributor_Name);
            system.debug('==ListSampleBook==' + ListSampleBook);             
            for(Sample_Book__c SBobj : ListSampleBook){
                Family_set.add(SBobj.Product_Family__c);
                MapSamplebook.put(SBobj.product__r.name,SBobj);
            }
            
            lstFamilies.addall(Family_set);
        }
        return lstFamilies;     
    }
    
    @AuraEnabled
    public static list<string> FetchProducts(string selected_family){
        List<string> Listproducts = New List<string>();
        set<string> set_type = New set<string>();
        
        Distributor_Name = getDistributor_Name();
        system.debug('==selected_family=='  + selected_family + '==Distributor_Name==' + Distributor_Name);
        
        for(Sample_Book__c SBobj : [select id,Product__c,Product__r.name,Value__c,Product__r.Family,Account__c from Sample_Book__c where Product__r.Family =: selected_family and name =: Distributor_Name and Product__r.Non_Standard_Sample__c = false limit 1000]){
            if(SBobj.Product__c != null){
                 Listproducts.add(SBobj.Product__r.name);    
            }
         }
        
        system.debug('==Listproducts==' + Listproducts);
        return Listproducts;
    }
     
   @AuraEnabled
    public static Sample_Inventory__c FetchInventory(string selectedProduct){
        //string inventory_id;
        //list<Sample_Inventory__c> ListSampInv = new list<Sample_Inventory__c>();
        //[select  id,name ,Quantity_Available__c,Sample_Hub__r.name,Product__r.name,product__r.family  from Sample_Inventory__c where Product__c =: selected_product and Sample_Hub__r.name =: SRobj.Sample_Hub__c]        
        //ListSampInv = [select  id,name ,Quantity_Available__c,Sample_Hub__r.name,Product__r.name,product__r.family  from Sample_Inventory__c where Product__c =: selectedProduct limit 1];        
        
        system.debug('==FetchInventory == selectedProduct==' + selectedProduct);
        
        Sample_Inventory__c SampleInvobj = new Sample_Inventory__c();
        List<Sample_Inventory__c> ListInv = new List<Sample_Inventory__c>();   
        ListInv = [select  id,name ,Quantity_Available__c,Sample_Hub__r.name,Product__r.name,product__r.family  from Sample_Inventory__c where Product__r.name =: selectedProduct limit 1];
        
        if(ListInv.size() > 0)
          SampleInvobj = ListInv[0];
        
        
        return SampleInvobj;
    }

    
    @AuraEnabled
    public static boolean SaveData2(integer Requested_Qty,string selectedProduct, string SampleReq_id){
     //throw new AuraHandledException('you can not order more than 50');   
        boolean DMLsuccess = true;
        system.debug('==SaveData == selectedProduct==' + Requested_Qty + '==selectedProduct==' + selectedProduct + '==SampleReq_id==' + SampleReq_id );
        system.debug('==SaveData == MapSamplebook==' + MapSamplebook );
        
        
        List<Sample_Inventory__c> ListInv = new List<Sample_Inventory__c>();   
        Sample_Inventory__c SampleInvobj = new Sample_Inventory__c();
        ListInv = [select  id,name ,Quantity_Available__c,Sample_Hub__r.name,Product__r.name,product__r.family  from Sample_Inventory__c where Product__r.name =: selectedProduct limit 1];
        
        if(ListInv.size() > 0)
          SampleInvobj = ListInv[0];
        
        if(Requested_Qty == null){
            DMLsuccess = false; 
            string ErrMsg = 'Product and Requested Quantity are required';
            AuraHandledException ex = new AuraHandledException(ErrMsg);
            ex.setMessage(ErrMsg);
            throw ex;
        }
        
        
        if(Requested_Qty > SampleInvobj.Quantity_Available__c){
            DMLsuccess = false; 
            string ErrMsg1 = 'Quantity Requested can not be more than available quantity';
            AuraHandledException ex1 = new AuraHandledException(ErrMsg1);
            ex1.setMessage(ErrMsg1);
            throw ex1;
        }
        
        if(SampleInvobj.Quantity_Available__c == 0){
            DMLsuccess = false; 
            string ErrMsg2 = 'There is no quantity available for sampling, Please order other item';
            AuraHandledException ex2 = new AuraHandledException(ErrMsg2);
            ex2.setMessage(ErrMsg2);
            throw ex2;
        }
        
        list<Sample_book__c> lstSamplebook = new list<Sample_book__c>();
        decimal Sample_book_Value = 0;
        decimal Order_Value = 0;
        Distributor_Name = getDistributor_Name();
        lstSamplebook = getProductValue(Distributor_Name,selectedProduct);
        
        if(lstSamplebook.size() > 0){
           Sample_book_Value = lstSamplebook[0].value__c; 
            Order_Value = Sample_book_Value * Requested_Qty;
        }
        
        if( Order_Value > 50){
            DMLsuccess = false; 
            string ErrMsg3 = 'Sampling Order can not more than $50';
            AuraHandledException ex3 = new AuraHandledException(ErrMsg3);
            ex3.setMessage(ErrMsg3);
            throw ex3;
        }
        
        
        List<Sample_Request_line__c> ListSRL = new List<Sample_Request_line__c>();
        ListSRL = [select id,name,product__c from Sample_Request_Line__c where id =: SampleReq_id and product__c =: selectedProduct];
        
        if( ListSRL.size() > 0 ){
            DMLsuccess = false; 
            string ErrMsg4 = 'Part Number already exist for this Sample Request, Please select another';
            AuraHandledException ex4 = new AuraHandledException(ErrMsg4);
            ex4.setMessage(ErrMsg4);
            throw ex4;
        }
        
        if(SampleReq_id == null){
            Sample_Request_Line__c Obj_SRL = new Sample_Request_Line__c();
            Obj_SRL.Sample_Request__c = SampleReq_id;
            Obj_SRL.status__c = 'Draft';
            Obj_SRL.value__c = Order_Value;
            Obj_SRL.Sample_Inventory__c = SampleInvobj.id;
            
            try{
               insert Obj_SRL; 
               DMLsuccess = true;
               system.debug('==Obj_SRL==' + Obj_SRL);    
            }Catch(exception e){
                DMLsuccess = false; 
                string ErrMsg5 = 'Some Error Occured while saving the record :' + e;
                AuraHandledException ex5 = new AuraHandledException(ErrMsg5); 
                ex5.setMessage(ErrMsg5);
                throw ex5;
            }
            
            
            
        }
                
        return DMLsuccess;
    }
    

    public static string getDistributor_Name(){
        return [select Distributor_Name__c from user where id =: userinfo.getuserid()].Distributor_Name__c;
    }
    
    public static list<Sample_Book__c> getSampleBook(string Disti_Name){
        return [ select id,Product__c,Product__r.name,Value__c, Product_Family__c from Sample_Book__c where name = : Disti_Name order by Product_Family__c];
    }
    
    public static list<Sample_Book__c> getProductValue(string Disti_Name,string prod_name){
        return [ select id,Product__c,Product__r.name,Value__c, Product_Family__c from Sample_Book__c where name = : Disti_Name and Product__r.name =: prod_name limit 1];
    }
    
}