• Learnerrr
  • NEWBIE
  • 40 Points
  • Member since 2018


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 20
    Questions
  • 12
    Replies
public class abc{
	private final Id AccountId; 
	
	 public abc(ApexPages.StandardController stdController) {
       Account acc = (Account)stdController.getRecord();
       accountId = acc.Id;
   }
	
	@AuraEnabled
	public static Account getAccount(){
		 Account acc = [select Name,Phone,Id from Account where Id= :accountId];
		System.debug(acc.Id);
		return acc;
	}
}

 
Please let me know hoe to resolve this error as I am new in SFDC developement

Create a field on the Account object called 'Number_of_Contacts__c' of type Number. This field will hold the total number of Contacts for the Account.
Create an Apex class called 'AccountProcessor' that contains a 'countContacts' method that accepts a List of Account IDs. This method must use the @future annotation.
For each Account ID passed to the method, count the number of Contact records associated to it and update the 'Number_of_Contacts__c' field with this value.
public class AccountProcessor {
    @future
    public static void countContacts(List<ID> accid1)
    {
      List<Account> acc = [select Id,name from account where Id In: accid1];
       List<Account> updateacc = new List<Account>();
        for (Account a1 : acc)
        {
            a1.Number_of_Contacts__c = [select count() from contact where accountId IN: a1.Id];
            updateacc.add(a1);
            
        }
        update updateacc;
    }

}


Thanks :)

 
Standard page is already given for UI then Why we need to create custom page?
else if(ApexPages.currentPage().getParameters().get('RecordType') =='0127F000000erM4'){
             PageReference pageRef1 = new PageReference('/apex/Case_CustomEditPage');
             pageRef1.setRedirect(true);
             return pageRef1;
             }

 
<apex:page controller="OppotunityByList" >
  <apex:form >
        <apex:pageBlock title="Display Opportunity Details: ">
            
            <apex:pageBlockSection >
            <apex:outputLabel value="opportunity Name: " />
            
            <apex:selectlist value="{!oppid}" size="1" >
                <apex:selectOptions value="{!oppnames}" />
                <apex:actionSupport action="{!getDetails}" event="onchange" rerender="display"/>
            </apex:selectlist>
            </apex:pageBlockSection>
          
                <apex:pageBlockSection id="display" title="Account Details">
                     <apex:pageBlockTable value="{!SelectedOpp}" var="a">   
  
                    <apex:column HeaderValue="Name" value="{!a.Name}"/>
                    <apex:column HeaderValue="Stage Name" value="{!a.StageName}"/>
                      </apex:pageBlockTable> 
                </apex:pageBlockSection>    
        
           
           
        </apex:pageBlock>
    </apex:form>
 
public class OppotunityByList {

    public String oppnames { get; set; }
    public String oppid { get; set; }
    public Opportunity SelectedOpp{get;set;}
    
    public list<selectoption> getoppnames() {
        
        list<selectoption> accoptions = new list<selectoption>();
        for (opportunity p : [select id, stageName from opportunity]){
            accoptions.add(new selectoption(p.id, p.name));
        }  
        return accoptions;
    } 
    
    public void  getDetails() {
        
        SelectedOpp = new Opportunity();
        SelectedOpp = [SELECT id, Name, stageName FROM Opportunity WHERE stageName=:oppid ];
        
    }
   
   
}

 
public class abc{
	private final Id AccountId; 
	
	 public abc(ApexPages.StandardController stdController) {
       Account acc = (Account)stdController.getRecord();
       accountId = acc.Id;
   }
	
	@AuraEnabled
	public static Account getAccount(){
		 Account acc = [select Name,Phone,Id from Account where Id= :accountId];
		System.debug(acc.Id);
		return acc;
	}
}

 
Hi All,
   
   I got this requirement  by using VisualForce page.So any one can help me.