You need to sign in to do that
Don't have an account?

This page has an error. You might just need to refresh it. Unable to find action 'Search' on the controller of c:LC_SearchAccount_v2 Failing descriptor: {c:LC_SearchAccount_v2}
Component
<aura:component controller="Class_Searchtext">
<aura:attribute name="acc" type="Account[]" />
<aura:attribute name="Search" type="String" />
<lightning:card class="slds-m-around_medium" title="Accounts" iconName="standard:account">
<aura:set attribute="actions">
<lightning:buttonGroup>
<lightning:button label="New" />
<lightning:button label="Import" />
<lightning:button label="Printable" />
</lightning:buttonGroup>
</aura:set>
<div class="slds-m-around_medium">
<lightning:layout>
<lightning:layoutItem size="6">
<lightning:input label="Enter name to search" value="{!v.Search}" />
</lightning:layoutItem>
<lightning:layoutItem size="6">
<lightning:button label="Search" onclick="{!c.click}" />
</lightning:layoutItem>
</lightning:layout>
<lightning:layout multipleRows="true">
<aura:iteration items="{!v.acc}" var="a">
<lightning:layoutItem size="3" padding="around-small">
Name:{!a.Name}
Phone:{!a.Phone}
Rating:{!a.Rating}
</lightning:layoutItem>
</aura:iteration>
</lightning:layout>
</div>
</lightning:card>
</aura:component>
Apex class
public class Class_Searchtext
{
@AuraEnabled
Public Static List<Account> getaccount(String searchtext)
{
String query = 'select id,name,industry,phone,rating from Account where name like \'%'+searchtext+ '%\'';
List<Account> accounts = Database.query(query);
Return accounts;
}
}
Controller
({
click : function(component, event, helper)
{
var a= component.get("c.Search");
var action = component.get("c.getaccount");
action.setParams({"searchtext":a});
action.setCallback(this,function(response){
var st= response.getState();
if(st=='SUCCESS')
{
var r = response.getReturnValue();
alert('search results are ');
component.set("v.acc",r);
}
});
$A.enqueueAction(action);
}
})
Application
<aura:application extends="force:slds">
<c:LC_SearchAccount_v2/>
</aura:application>
<aura:component controller="Class_Searchtext">
<aura:attribute name="acc" type="Account[]" />
<aura:attribute name="Search" type="String" />
<lightning:card class="slds-m-around_medium" title="Accounts" iconName="standard:account">
<aura:set attribute="actions">
<lightning:buttonGroup>
<lightning:button label="New" />
<lightning:button label="Import" />
<lightning:button label="Printable" />
</lightning:buttonGroup>
</aura:set>
<div class="slds-m-around_medium">
<lightning:layout>
<lightning:layoutItem size="6">
<lightning:input label="Enter name to search" value="{!v.Search}" />
</lightning:layoutItem>
<lightning:layoutItem size="6">
<lightning:button label="Search" onclick="{!c.click}" />
</lightning:layoutItem>
</lightning:layout>
<lightning:layout multipleRows="true">
<aura:iteration items="{!v.acc}" var="a">
<lightning:layoutItem size="3" padding="around-small">
Name:{!a.Name}
Phone:{!a.Phone}
Rating:{!a.Rating}
</lightning:layoutItem>
</aura:iteration>
</lightning:layout>
</div>
</lightning:card>
</aura:component>
Apex class
public class Class_Searchtext
{
@AuraEnabled
Public Static List<Account> getaccount(String searchtext)
{
String query = 'select id,name,industry,phone,rating from Account where name like \'%'+searchtext+ '%\'';
List<Account> accounts = Database.query(query);
Return accounts;
}
}
Controller
({
click : function(component, event, helper)
{
var a= component.get("c.Search");
var action = component.get("c.getaccount");
action.setParams({"searchtext":a});
action.setCallback(this,function(response){
var st= response.getState();
if(st=='SUCCESS')
{
var r = response.getReturnValue();
alert('search results are ');
component.set("v.acc",r);
}
});
$A.enqueueAction(action);
}
})
Application
<aura:application extends="force:slds">
<c:LC_SearchAccount_v2/>
</aura:application>
There was a small mistake in the controller. Can you please change it as below and check. Instead of
you re using
Can you make this change and check.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
There was a small mistake in the controller. Can you please change it as below and check. Instead of
you re using
Can you make this change and check.
If this solution helps, Please mark it as best answer.
Thanks,