• brahmanaidu
  • NEWBIE
  • 29 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 5
    Questions
  • 9
    Replies
ChildComponent
--------------
<aura:component >
    <ui:button label="click me" press="{!c.hanldeClick}"/>
    <aura:registerEvent name="componentevent" type="c:SimpleComponentEvent"/>
</aura:component>

SimpleComponentEvent.evt
------------------------
<aura:event type="component" description="component" >
 <aura:attribute name="message" type="string"/>
    </aura:event>
    
    controller
    ------------
    ({
    hanldeClick : function(component, event, helper) {
        var v1=component.get("componentevent");
        v1.setParams({
            "message":'Welcome to sfdcscenarios.blogspot.com'
        });
        v1.fire();
        
        
    }
})


ParentComponent
---------------
<aura:component >
    <aura:attribute name="EventMessage" type="String"/>
    <aura:handler name="componentevent" event="c:SimpleComponentEvent" action="{!c.hanldeParent}"/>
    <c:ChildComponent/>
    {!v.EventMessage}
</aura:component>




Controller
-----------
({
    handleParent: function(component, event, helper) {
        var message = event.getParam("message"); 
        cmp.set("v.EventMessage", message + 'brahmanaidu');         
    } 
    
    
})
<aura:component controller="ListAccounts">
  <aura:attribute name="accounts" type="List" />
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="accList" type="list"/>
  <!--
    Use a data table from the Lightning Design System:
    https://www.lightningdesignsystem.com/components/data-tables/
  -->
  <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
                  <th scope="col"><div class="slds-truncate" title="Select">Select</div></th>

        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
        <th scope="col"><div class="slds-truncate" title="Site">Site</div></th>
       
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.accounts}" var="account">
        <tr>
          <th scope="row">
              <ui:inputCheckbox />
            </th>

          <th scope="row"><div class="slds-truncate" title="{!account.Id}">{!account.Id}</div></th>
          <td><div class="slds-truncate" title="{!account.Name}">{!account.Name}</div></td>
          <td><div class="slds-truncate" title="{!account.Site}">{!account.Site}</div></td>
          
          <td>
            
          </td>
        </tr>
      </aura:iteration>
        <ui:button label="Aprove" press="{!c.approve}"/>
    </tbody>
  </table>
</aura:component>



({
  // Fetch the accounts from the Apex controller
  doInit: function(component,event,helper) {
    var action = component.get('c.getAccounts');
    // Set up the callback
    var self = this;
    action.setCallback(this, function(actionResult) {
     component.set('v.accounts', actionResult.getReturnValue());
    });
    $A.enqueueAction(action);
  },
    approve: function(component,event,helper) {
    var a = component.get('c.getApproved');
        console.log('checking the status');
        a.setCallback(this, function(response) {
     component.set('v.accList', response.getReturnValue());
    });
    $A.enqueueAction(a);
    
    },
    
})









public class ListAccounts {
  @AuraEnabled
  public static List<Account> getAccounts() {
    return [SELECT Id, name,site from Account Limit 6];
  }
    @AuraEnabled
    public static  void getApproved(){
        List<Account> accs=[select Id,Name,Site from Account];
        for(Account a:accs){
            a.Site='Approved';
        }
        
        
        
    }
    
}












 
public class CreateRecord
{
public static void createAccount(){
    List<Account> accList=Trigger.new;
    List<Account> accs=new List<Account>();
    for(Account a:accList){
        Account a1=new Account();
        a.Name='mbnchowdary';
        a.Site='mandalapu';
        a.Email__c='mbnchowdarysfdc@gmail.com';
        accs.add(a);
        System.debug(accs);
        
    }
    
    insert accs;

}    
    
}


<aura:component  controller="RecordInsertion">
    <ui:button label="click"  aura:id="button" press="{!c.doPerform}"/>
</aura:component>


({
    
    
               doPerform:function(component,event,helper){
               console.log('method is called');
                   var action=component.get('c.createAccount');
                       action.setParams({

            });
        $A.enqueueAction(action)
                   
                   
                   
        
        
    }
    
    
})
trigger ContactTrigger on Contact (before update) {
    set<id> ids=new set<id>();
    if(Trigger.isUpdate){
        for(Contact con:Trigger.new){
            if(con.AccountId==null){
                ids.add(con.Id);
            }
        }
    }
    List<Contact> condata=[select Id,Name from Contact where Id in:ids];
    if(condata.size()>0&& condata!=null){
        
    }
     delete condata;    
}
<aura:component controller="ListAccounts">
  <aura:attribute name="accounts" type="List" />
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
    <aura:attribute name="accList" type="list"/>
  <!--
    Use a data table from the Lightning Design System:
    https://www.lightningdesignsystem.com/components/data-tables/
  -->
  <table class="slds-table slds-table--bordered slds-table--striped slds-table--cell-buffer slds-table--fixed-layout">
    <thead>
      <tr class="slds-text-heading--label">
                  <th scope="col"><div class="slds-truncate" title="Select">Select</div></th>

        <th scope="col"><div class="slds-truncate" title="ID">ID</div></th>
        <th scope="col"><div class="slds-truncate" title="Name">Name</div></th>
        <th scope="col"><div class="slds-truncate" title="Site">Site</div></th>
       
      </tr>
    </thead>
    <tbody>
      <!-- Use the Apex model and controller to fetch server side data -->
      <aura:iteration items="{!v.accounts}" var="account">
        <tr>
          <th scope="row">
              <ui:inputCheckbox />
            </th>

          <th scope="row"><div class="slds-truncate" title="{!account.Id}">{!account.Id}</div></th>
          <td><div class="slds-truncate" title="{!account.Name}">{!account.Name}</div></td>
          <td><div class="slds-truncate" title="{!account.Site}">{!account.Site}</div></td>
          
          <td>
            
          </td>
        </tr>
      </aura:iteration>
        <ui:button label="Aprove" press="{!c.approve}"/>
    </tbody>
  </table>
</aura:component>



({
  // Fetch the accounts from the Apex controller
  doInit: function(component,event,helper) {
    var action = component.get('c.getAccounts');
    // Set up the callback
    var self = this;
    action.setCallback(this, function(actionResult) {
     component.set('v.accounts', actionResult.getReturnValue());
    });
    $A.enqueueAction(action);
  },
    approve: function(component,event,helper) {
    var a = component.get('c.getApproved');
        console.log('checking the status');
        a.setCallback(this, function(response) {
     component.set('v.accList', response.getReturnValue());
    });
    $A.enqueueAction(a);
    
    },
    
})









public class ListAccounts {
  @AuraEnabled
  public static List<Account> getAccounts() {
    return [SELECT Id, name,site from Account Limit 6];
  }
    @AuraEnabled
    public static  void getApproved(){
        List<Account> accs=[select Id,Name,Site from Account];
        for(Account a:accs){
            a.Site='Approved';
        }
        
        
        
    }
    
}












 
public class CreateRecord
{
public static void createAccount(){
    List<Account> accList=Trigger.new;
    List<Account> accs=new List<Account>();
    for(Account a:accList){
        Account a1=new Account();
        a.Name='mbnchowdary';
        a.Site='mandalapu';
        a.Email__c='mbnchowdarysfdc@gmail.com';
        accs.add(a);
        System.debug(accs);
        
    }
    
    insert accs;

}    
    
}


<aura:component  controller="RecordInsertion">
    <ui:button label="click"  aura:id="button" press="{!c.doPerform}"/>
</aura:component>


({
    
    
               doPerform:function(component,event,helper){
               console.log('method is called');
                   var action=component.get('c.createAccount');
                       action.setParams({

            });
        $A.enqueueAction(action)
                   
                   
                   
        
        
    }
    
    
})