• Nagaraju Mogili 31
  • NEWBIE
  • 20 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 9
    Questions
  • 5
    Replies
public class PageBlockTable_cntrlr {
   Public List<Account> acclist {get;set;}
   
   public PageBlockTable_cntrlr(){
     acclist = new List<Account>([select Id,Name,(select firstname,LastName from contacts) from Account]);
    }
}

======

<apex:page controller="PageBlockTable_cntrlr" >
<apex:form >
   <apex:pageBlock title="List OF Accounts">
      <apex:pageBlockTable value="{!acclist}" var="x">
          <apex:column value="{!x.Id}"/>
          <apex:column value="{!x.Name}"/><tr>
          <apex:pageBlockTable value="{!x.contacts}" var="y">
             <apex:column value="{!y.firstname}"/>
             <apex:column value="{!y.LastName}"/>
          </apex:pageBlockTable> </tr>
      </apex:pageBlockTable>
   </apex:pageBlock>
</apex:form>   
</apex:page>
=============
with this I can able to display the single Account details only, how can i display the contact details beside of Account object
User-added image

Here is Mycode:  Apex controller ===========

public class records {
    public Schema.contact con {get;set;}
    public list<Schema.contact> conlist {get;set;}
    
    public String regionValue {get;set;}   
    public List<SelectOption> regionOptions {get;set;}
    public List<Schema.contact> filteredcontacts {get;set;}

    private integer totalRecs = 0;     
    private integer index = 0;
    private integer blockSize = 10;
     
   public records(){
           totalRecs = [select count() from contact];
        
   }
   
   
    public records(ApexPages.StandardController controller) {
          regionOptions = new List<SelectOption>();
          regionOptions.add(new SelectOption('Web','Web'));
          regionOptions.add(new SelectOption('Phone Inquiry','Phone Inquiry'));
          regionOptions.add(new SelectOption('Partner Referral','Partner Referral'));
          regionOptions.add(new SelectOption('Purchased List','Purchased List'));
          regionOptions.add(new SelectOption('Other','Other'));
   }
   
      public void updatefilteredcontacts(){
         filteredcontacts = [select firstname,LastName from contact where contact.Leadsource =: regionValue];
      }
      
    public list<Schema.contact> getcontacts(){
      list<Schema.contact> conlist = new list<Schema.contact>();
       conlist =[select firstname,lastName,LeadSource from contact   LIMIT:blockSize OFFSET :index];
      return conlist;
      }
      
       
    public void beginning(){    
        index = 0;
    }
    
     public void previous(){
    
        index = index - blockSize;
    }
    

   public void next(){
        index = index + blockSize;
    }

    public void end(){
        index = totalrecs - math.mod(totalRecs,blockSize);
    }   
    
      public boolean getprev(){
        if(index == 0)
        return true;
        else
        return false;
    }  
    
      public boolean getnxt(){    
        if((index + blockSize) > totalRecs)
        return true;
        else
        return false;
    }     
   }

=============== VF Page ================================

<apex:page controller="records">
   <apex:form >
          <!--<apex:selectList value="{!regionValue}" size="1"> 
             <apex:selectOptions value="{!regionOptions}"/>
          </apex:selectList>
         <apex:commandButton value="Update Contacts" action="{!updatefilteredcontacts}"/>-->

   
           <apex:pageBlock >
             <apex:pageBlockSection title="Filters">
                 <apex:inputText value="{!con.FirstName}" label="FirstName"/>
                 <apex:inputText value="{!con.LastName}" label="Last Name"/>
                 <apex:inputField value="{!con.Leadsource}" />
             </apex:pageBlockSection>
          </apex:pageBlock>
    
     <apex:pageBlock id="details">
         <apex:pageblockButtons >      
          <apex:panelGrid columns="4">
            <apex:commandButton value="Begining" rerender="details" action="{!beginning}" disabled="{!prev}"/>
            <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
            <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
            <apex:commandButton value="Ending" rerender="details" action="{!end}" disabled="{!nxt}"/>                                    
        </apex:panelGrid>    
         </apex:pageblockButtons>            
      
          <apex:pageBlockTable value="{!contacts}" var="x">
              <apex:column value="{!x.FirstName}"/>
              <apex:column value="{!x.lastName}"/>
              <apex:column value="{!x.LeadSource}"/>
          </apex:pageBlockTable>             
    </apex:pageBlock>
    
       <apex:pageBlock >
       <apex:pageBlockSection title="Displaying the contacts based on Search">
           <apex:pageBlockTable value="{!filteredcontacts}" var="contac">
              <apex:column value="{!contac.firstName}"/>
           </apex:pageBlockTable>
       </apex:pageBlockSection> 
     </apex:pageBlock>  
    </apex:form>
    <apex:slds />
</apex:page>
 
Here is My code ::

Apex controller---

public class Numbers {

     @AuraEnabled
    public static void numbers (){
       List<Integer> intlist = new List<Integer>();
        for(Integer i=0; i<=100 ; i++){
            intlist.add(i);
         }
      }
}

================== 
component :

<aura:component controller="Numbers">
    <aura:attribute name="Number" type ="Integer"/>
    
    <aura:iteration items="{!Number}" var="x">
         {!x}
    </aura:iteration>
    
    <aura:handler name="init" value="{!this}" action ="{!c.doInIt}"/>
</aura:component>
================================
client-side controller:

({
    doInIt : function(component, event, helper) {
          
        var action = component.get("c.numbers");
        
        action.setCallback(this, function(response){
            component.set("v.Number", response.getReturnValue());
        });
        $A.enqueueAction(action);
    }
})
========
 
Here is my code,  I was not able to find the error ..
====================================
component :
<aura:component controller = "opplist">
    <aura:attribute name="opportunities" type="list"/>
    <aura:handler name="init" value="doinit" action="{!v.doinit}"/>
    <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="ID">ID</div></th>
            <th scope="col"><div class="slds-truncate" title="Name">AccountId</div></th>
            <th scope="col"><div class="slds-truncate" title="Type">probability</div></th>
            <th scope="col"><div class="slds-truncate" title="Number Of Employees">stageName</div></th>
            <th scope="col"><div class="slds-truncate" title="Ticker Symbol">Close Date</div></th>
            <th scope="col"><div class="slds-truncate" title="Phone">Opportunity Currency</div></th>
            <th scope="col"><div class="slds-truncate" title="Delete">Amount</div></th>
          </tr>
        </thead>
        <tbody>
            <aura:iteration items="{!v.opportunities}" var ="x">
                <tr>
          <th scope="row"><div class="slds-truncate" title="{!account.Id}">{!x.Id}</div></th>
          <td><div class="slds-truncate" title="{!account.Name}">{!x.AccountId}</div></td>
          <td><div class="slds-truncate" title="{!account.Type}">{!x.probability}</div></td>
          <td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.stageName}</div></td>
          <td><div class="slds-truncate" title="{!account.NumberOfEmployees}">{!x.closeDate}</div></td>
          <td><div class="slds-truncate" title="{!account.TickerSymbol}">{!x.OpportunityCurrency}</div></td>
          <td><div class="slds-truncate" title="{!account.Phone}">{!x.Amount}</div></td>
                </tr>
           </aura:iteration>                            
        </tbody>
    </table>
</aura:component>
===============================================
controller :
public class opplist {
   
    @AuraEnabled
    public static list<opportunity> getopplist(){
        
        list<opportunity> opps = new list<opportunity>([select Id,AccountId,probability,stageName from opportunity]);
        return opps;
    }
}
===========================
Helper controller :

({
    getopplist : function(component) {
         var action = component.get("v.getopplist");
        
        var self = this;
        action.setCallback(this, function(actionResult) {
            
            component.set('v.getopplist', actionResult.getReturnValue());
         });
          $A.enqueueAction(action);
    }
})

================================================
component controller

({
    doinit : function(component, event, helper) {
        helper.getAccountlist(component);
    }
})

 
User-added image

Here is Mycode:  Apex controller ===========

public class records {
    public Schema.contact con {get;set;}
    public list<Schema.contact> conlist {get;set;}
    
    public String regionValue {get;set;}   
    public List<SelectOption> regionOptions {get;set;}
    public List<Schema.contact> filteredcontacts {get;set;}

    private integer totalRecs = 0;     
    private integer index = 0;
    private integer blockSize = 10;
     
   public records(){
           totalRecs = [select count() from contact];
        
   }
   
   
    public records(ApexPages.StandardController controller) {
          regionOptions = new List<SelectOption>();
          regionOptions.add(new SelectOption('Web','Web'));
          regionOptions.add(new SelectOption('Phone Inquiry','Phone Inquiry'));
          regionOptions.add(new SelectOption('Partner Referral','Partner Referral'));
          regionOptions.add(new SelectOption('Purchased List','Purchased List'));
          regionOptions.add(new SelectOption('Other','Other'));
   }
   
      public void updatefilteredcontacts(){
         filteredcontacts = [select firstname,LastName from contact where contact.Leadsource =: regionValue];
      }
      
    public list<Schema.contact> getcontacts(){
      list<Schema.contact> conlist = new list<Schema.contact>();
       conlist =[select firstname,lastName,LeadSource from contact   LIMIT:blockSize OFFSET :index];
      return conlist;
      }
      
       
    public void beginning(){    
        index = 0;
    }
    
     public void previous(){
    
        index = index - blockSize;
    }
    

   public void next(){
        index = index + blockSize;
    }

    public void end(){
        index = totalrecs - math.mod(totalRecs,blockSize);
    }   
    
      public boolean getprev(){
        if(index == 0)
        return true;
        else
        return false;
    }  
    
      public boolean getnxt(){    
        if((index + blockSize) > totalRecs)
        return true;
        else
        return false;
    }     
   }

=============== VF Page ================================

<apex:page controller="records">
   <apex:form >
          <!--<apex:selectList value="{!regionValue}" size="1"> 
             <apex:selectOptions value="{!regionOptions}"/>
          </apex:selectList>
         <apex:commandButton value="Update Contacts" action="{!updatefilteredcontacts}"/>-->

   
           <apex:pageBlock >
             <apex:pageBlockSection title="Filters">
                 <apex:inputText value="{!con.FirstName}" label="FirstName"/>
                 <apex:inputText value="{!con.LastName}" label="Last Name"/>
                 <apex:inputField value="{!con.Leadsource}" />
             </apex:pageBlockSection>
          </apex:pageBlock>
    
     <apex:pageBlock id="details">
         <apex:pageblockButtons >      
          <apex:panelGrid columns="4">
            <apex:commandButton value="Begining" rerender="details" action="{!beginning}" disabled="{!prev}"/>
            <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
            <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
            <apex:commandButton value="Ending" rerender="details" action="{!end}" disabled="{!nxt}"/>                                    
        </apex:panelGrid>    
         </apex:pageblockButtons>            
      
          <apex:pageBlockTable value="{!contacts}" var="x">
              <apex:column value="{!x.FirstName}"/>
              <apex:column value="{!x.lastName}"/>
              <apex:column value="{!x.LeadSource}"/>
          </apex:pageBlockTable>             
    </apex:pageBlock>
    
       <apex:pageBlock >
       <apex:pageBlockSection title="Displaying the contacts based on Search">
           <apex:pageBlockTable value="{!filteredcontacts}" var="contac">
              <apex:column value="{!contac.firstName}"/>
           </apex:pageBlockTable>
       </apex:pageBlockSection> 
     </apex:pageBlock>  
    </apex:form>
    <apex:slds />
</apex:page>
 
Hi All,
I'm new to salesforce and started working on Trailhead's. I facing issue with the Trigger Challenge. Here is the triger code im writing 

trigger AccountAddressTrigger on Account (before insert) {
    for(Account a : Trigger.new){
        if(a.Match_Billing_Address__c && a.BillingPostalCode != null){
            a.ShippingPostalCode = a.BillingPostalCode;
        }
    }
    
}

but i'm getting the following error. Not sure where i'm doing wrong. can someone please help me here. Thanks in advance.

System.DmlException: Insert failed. First exception on row 0; first error: CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY, TestTrigger: execution of AfterInsert caused by: System.NullPointerException: Attempt to de-reference a null object Trigger.TestTrigger: line 3, column 1: []

Hi,

I have overridden new and edit of a custom object with a VF page which allows the user to search and then insert records to the custom object. What I want to do is when a user clicks edit infront of the record from the related list, the fields of the object get auto populated in the search fields of my VF page. I was trying to pass parameters (as we normally do in case we need opportunity name to be defaulted with some value) through URL but it is not working is there another way to do the same.

 

Thanks in advance 

Rasesh