+ Start a Discussion
Praveen MeharPraveen Mehar 

getting error as [Component is not defined] Full error => This page has an error. You might just need to refresh it. Action failed: c:parasm$controller$invoke [Component is not defined] Failing descriptor: {c:parasm$controller$invoke}

public class params1 {
    @AuraEnabled
    public static List<Opportunity> ops(String oStagename,String oType){
        List<Opportunity> opportunities=[select Id,Name,Stagename,Type from Opportunity where StageName=:oStagename and Type=:oType limit 4];
        return opportunities;
    }
}


<aura:component controller="params1">
    <aura:attribute name="optylist" type="List"/>
    <lightning:input label="StageName" aura:id="sname" />
    <lightning:input label="CustomerType" aura:id="cust"/>
    <lightning:button label="Submit" onclick="{!c.invoke}"/>
    
    <aura:iteration items="{!v.optylist}" var="a">
    	<p>{!a.Name} &nbsp;&nbsp;&nbsp;{!a.Stagename}&nbsp;&nbsp;&nbsp;{!a.Type}</p>
    </aura:iteration>
</aura:component>


({
    invoke : function(component, event, helper) {
        var stagename=component.find("sname").get("v.value");
        var type=Component.find("cust").get("v.value");
        
        var action=component.get("c.ops");
        action.setParams({"oStagename":stagename,"oType":type});
        action.setCallback(this,function(response){
            var state=response.getState();
            if(state==='SUCCESS'){
                console.log('Operation successful');
                component.set("v.optylist",response.getReturnValue());
            }
        })
        $A.enqueueAction(action);
    }
       
})


<aura:application extends="force:slds">
	<c:parasm />
</aura:application>

 
Best Answer chosen by Praveen Mehar
Sachin HoodaSachin Hooda
Hi Praveen,
You've made a little mistake. 
Since JS is a case-sensitive language, please change 
var type=Component.find("cust").get("v.value");
to 
var type=component.find("cust").get("v.value");
_____
Regards,
Sachin
(: