• pavan kumar 1156
  • NEWBIE
  • 20 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 10
    Questions
  • 3
    Replies
when user select an account from the picklist, all opportunities which are related to that account should be displayed in a table with checkbox in a first column of each row, there should be one master checkbox in the header of the table to select or deselect all opportunities in one click.
since Christmas myself and no of other users across multiple business lines have noticed that reports are taking a lot longer to run, often timeout any optimization to improve this?
<apex:page controller="AccountSelectClassController" sidebar="false">
         <script type="text/javascript">
         function selectAllCheckboxes(obj,receivedInputID)
         {
         var inputCheckBox = document.getElementsByTagName("input");
         for(var i=0; i<inputCheckBox.length; i++)
         {
         if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1)
          {
           inputCheckBox[i].checked = obj.checked;
                }
             }
             }
       </script>

        <apex:form >
        <apex:pageBlock >
        <apex:pageBlockButtons >
        <apex:commandButton value="Show Selected Accounts" action="{!processSelected}" rerender="table2"/>
         </apex:pageBlockButtons>
 
        <apex:pageblockSection title="All Accounts" collapsible="false" columns="2">
 
        <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">
                  <apex:column >
                  <apex:facet name="header">
                  <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
                   </apex:facet>
                   <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>
                   </apex:column>
                    <apex:column value="{!accWrap.acc.Name}" />
                    <apex:column value="{!accWrap.acc.BillingState}" />
                    <apex:column value="{!accWrap.acc.Phone}" />
          </apex:pageBlockTable>
 
                <apex:pageBlockTable value="{!selectedAccounts}" var="c" id="table2" title="Selected Accounts">
                    <apex:column value="{!c.Name}" headerValue="Account Name"/>
                    <apex:column value="{!c.BillingState}" headerValue="Billing State"/>
                    <apex:column value="{!c.Phone}" headerValue="Phone"/>
                </apex:pageBlockTable>
 
            </apex:pageblockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>
write a that the query organization having maximum sales volume in alist view in deceending order?
what is Refactoring in apex ?how can we use it? is there any scenarios to use it?
Apex class
-------------
public class StringStack {

      private List<String> stack;

    public StringStack()
    {
         stack = new List<String>();

    }

    public void push(String s)
    { 
        stack.add(s); 
    }
    public String pop() 
    {
       
    return stack.remove( lastItemIndex );
    }
    public String peak() 
    {

        return stack.get( lastItemIndex );

    }

 
    public Boolean isEmpty() 
    { 
        return stack.isEmpty();
    }
     

    // Helper Property

    private Integer lastItemIndex
    {
        get 
        { 
            return stack.size() - 1;
            }
    }

}



Test clas
------------
@isTest
public class TestStringStack 
 {
public static testmethod void StringStackcheck()
{
    //Instantiate a StringStack.

    StringStack stack = new StringStack();
 // Set up some test data.

    String bottomString = 'Bottom String';
    String middleString = 'Middle String';
    String topString = 'Top String';

      // Call the push() method with multiple objects

    stack.push(bottomString);

    stack.push(middleString);
    stack.push(topString);

    // Verify that the 'top' object is the object we expected

    String peakValue = stack.peak();

    System.assertEquals(topString, peakValue);

    // Verify that the order of the objects is as we expected
    String popValue = stack.pop();
    System.assertEquals(topString, popValue);
    popValue = stack.pop();
    System.assertEquals(middleString, popValue);
    popValue = stack.pop();
    System.assertEquals(bottomString, popValue);
    System.assert(stack.isEmpty());

}
 }
Need tomerge the accounts and findout the duplicatea and eliminate them?
actionFunction provides support for invoking controller action methods directly from JavaScript code using an AJAXrequest
Can any one pls provide clear view this is my assumption is it correct..?
Ie;the method can be executed whwn java script event is handeled by ajax request 
1<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
2  <apex:pageBlock >
3    <apex:pageBlockTable value="{!accounts}" var="a">
4      <apex:column value="{!a.name}"/>
5    </apex:pageBlockTable>
6  </apex:pageBlock>
7</apex:page>
in above example recordset variable sets varible with name accounts and agian why we have create a new variable with the name "a"?
can any on explain please
Can any one give  examples for apex and visualforce code  to analyse 
Apex class
-------------
public class StringStack {

      private List<String> stack;

    public StringStack()
    {
         stack = new List<String>();

    }

    public void push(String s)
    { 
        stack.add(s); 
    }
    public String pop() 
    {
       
    return stack.remove( lastItemIndex );
    }
    public String peak() 
    {

        return stack.get( lastItemIndex );

    }

 
    public Boolean isEmpty() 
    { 
        return stack.isEmpty();
    }
     

    // Helper Property

    private Integer lastItemIndex
    {
        get 
        { 
            return stack.size() - 1;
            }
    }

}



Test clas
------------
@isTest
public class TestStringStack 
 {
public static testmethod void StringStackcheck()
{
    //Instantiate a StringStack.

    StringStack stack = new StringStack();
 // Set up some test data.

    String bottomString = 'Bottom String';
    String middleString = 'Middle String';
    String topString = 'Top String';

      // Call the push() method with multiple objects

    stack.push(bottomString);

    stack.push(middleString);
    stack.push(topString);

    // Verify that the 'top' object is the object we expected

    String peakValue = stack.peak();

    System.assertEquals(topString, peakValue);

    // Verify that the order of the objects is as we expected
    String popValue = stack.pop();
    System.assertEquals(topString, popValue);
    popValue = stack.pop();
    System.assertEquals(middleString, popValue);
    popValue = stack.pop();
    System.assertEquals(bottomString, popValue);
    System.assert(stack.isEmpty());

}
 }
1<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
2  <apex:pageBlock >
3    <apex:pageBlockTable value="{!accounts}" var="a">
4      <apex:column value="{!a.name}"/>
5    </apex:pageBlockTable>
6  </apex:pageBlock>
7</apex:page>
in above example recordset variable sets varible with name accounts and agian why we have create a new variable with the name "a"?
can any on explain please
Yo Team,

I'm new to the apex development and really confuse how to use contructor in the Class. So I look other Sr.developer's code and mimic the apex class, I'm so lucky that works. But turn to Test, I kind stuck there. Following is my Apex class and test class(not working) I created, I truely appriate that if anyone could give me some advises.

Apex Class:

public class HouseholdpageController {
    List<Account> accounts;
    public Lead currentlead{get;set;}
    public ApexPages.StandardSetController stdCntrlr {get; set;}
    public HouseholdpageController (ApexPages.StandardController controller)
  {     
    this.currentlead = (Lead)controller.getRecord(); 
    }
    public List<Account> getAccounts(){
        currentlead = [ Select Id, Equifax_Household_ID__c from Lead where Id =: ApexPages.currentPage().getParameters().get('Id') ];
        if(currentlead.Equifax_Household_ID__c != null) accounts = [select name, Loan_Balance__c, Deposit_Balance__c from account where Equifax_Household_ID__c =: currentlead.Equifax_Household_ID__c];
     
        return accounts;
    }

}


Test Class(Error:System.QueryException: List has no rows for assignment to SObject)
/**
 * This class contains unit tests for validating the behavior of Apex classes
 * and triggers.
 *
 * Unit tests are class methods that verify whether a particular piece
 * of code is working properly. Unit test methods take no arguments,
 * commit no data to the database, and are flagged with the testMethod
 * keyword in the method definition.
 *
 * All test methods in an organization are executed whenever Apex code is deployed
 * to a production organization to confirm correctness, ensure code
 * coverage, and prevent regressions. All Apex classes are
 * required to have at least 75% code coverage in order to be deployed
 * to a production organization. In addition, all triggers must have some code coverage.
 * 
 * The @isTest class annotation indicates this class only contains test
 * methods. Classes defined with the @isTest annotation do not count against
 * the organization size limit for all Apex scripts.
 *
 * See the Apex Language Reference for more information about Testing and Code Coverage.
 */
@isTest
private class HouseholdpageControllerTest {
    static testMethod void UnitTest() {
        RecordType rt = [SELECT Id,Name FROM RecordType WHERE SobjectType='Account' AND Name = 'Person Account'];   
        RecordType lead = [select Id from RecordType where DeveloperName = 'Relationship_Expansion_Leads']; 
        
        Profile p = [
            select Id
            from Profile
            where Name = 'System Administrator'
        ];
        
        User u = new User(
            Alias = 'standt',
            Email = 'standarduser@testorg.com',
            EmailEncodingKey = 'UTF-8',
            LastName = 'Testing',
            LanguageLocaleKey = 'en_US',
            LocaleSidKey = 'en_US',
            ProfileId = p.Id,
            TimeZoneSidKey = 'America/Los_Angeles',
            UserName='1512434@dfe1.COM'
        );
        
        Account testAccount1 = new Account(       
          FirstName='Test Description', 
          LastName='Test Last Name',
          RecordTypeId = rt.Id,
        Equifax_Household_ID__c = '123',
        Loan_Balance__c = 321,
        Deposit_Balance__c  = 456
        );
        Lead testLead1 = new Lead(
            LastName = 'TEST Name 1',
            status = 'Open',
            Phone = '5165039576',
            Email = '1@1.com',
            Classification__c = 'Consumer',
            RecordTypeId = lead.Id,
            Equifax_Household_ID__c = '123'
        ); 
           Test.startTest();
            List<Account> results;
        
            System.runAs(u) {
                insert testLead1;
                insert testAccount1;
            HouseholdpageController ctrl = new HouseholdpageController(new ApexPages.StandardController(testLead1));
            results = ctrl.getAccounts();
            }
        Test.stopTest();
    }
}

Thanks,
Jason Liu