• Akansha Gupta
  • NEWBIE
  • 10 Points
  • Member since 2017

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 4
    Questions
  • 2
    Replies
Hi! Can someone help me with the test class for the following controller class
public with sharing class VFC92_BillingAddListController {
    
    public string id,Account;
    public list<Account_Billing_Address__c> SelectedAccount { get; set; }
    public Account CurrentAccount {get; set;}
    public String AccountName {get; set;}
    public Account_Billing_Address__c Address;
    public TR1__Closing_Report__c cr = new TR1__Closing_Report__c();
    public Id AccountId{get;set;}
    
    public VFC92_BillingAddListController() 
    {
        Account = ApexPages.currentPage().getParameters().get('Account');
        CurrentAccount = [Select Headquarters_Flag__c,ParentId from Account where Id =: Account];
        
        if(CurrentAccount.Headquarters_Flag__c)
        {
            SelectedAccount = [SELECT Id,Name FROM Account_Billing_Address__c 
                               where Status__c = 'Active' AND Account__c =: Account];
            AccountId = Account;
        }
        else
        {
            SelectedAccount = [SELECT Id,Name FROM Account_Billing_Address__c 
                               where Status__c = 'Active' AND Account__c =: CurrentAccount.ParentId];  
            AccountId = CurrentAccount.ParentId;
        }
        id = ApexPages.currentPage().getParameters().get('id');
    }
    
    
    public PageReference cancel() 
    {
        return new PageReference('/' + id).setRedirect(true);
    }
    
    public PageReference create() 
    { 
        PageReference pr = new PageReference('/apex/VFP93_CreateNewBillingAddress?closingreport='+id+'&accountid='+AccountId);
        return pr;
    }
    
    public PageReference save()
    { 
        return new PageReference('/' + id).setRedirect(true);
    }
    
    public PageReference elect() 
    {
        Address = [Select Billing_City__c,Billing_Street__c,Billing_State_Province__c,Billing_Zip_Postal_Code__c
                   from Account_Billing_Address__c 
                   where name =:AccountName AND Account__c =: AccountId ];
        cr.Id = id;
        cr.TR1__Billing_City__c = Address.Billing_City__c;
        cr.TR1__Billing_State__c = Address.Billing_State_Province__c;
        cr.TR1__Billing_Street__c = Address.Billing_Street__c;
        cr.TR1__Billing_Zip_Code__c = Address.Billing_Zip_Postal_Code__c;  
        update cr;
        return new PageReference('/' + id).setRedirect(true);
    } 
    
    
}
I have the following method which opens a new record page from a VF page. "Account" is a lookup field in the record page which has to be populated from the TR1__Account__c field in the Closing Report object. How do I achieve this? Here is the method I wrote.
public PageReference create() {
        id = ApexPages.currentPage().getParameters().get('id');
           cr = [Select TR1__Account__c from TR1__Closing_Report__c where Id =: id];
        accountId = cr.TR1__Account__c;
        PageReference pageRef = new PageReference('https://foiberia--devv11.cs88.my.salesforce.com/a2w/e?retURL=%2Fa2w%2Fo');
        pageRef.getParameters().put('Account',String.valueOf(accountId));
        return pageRef.setRedirect(true);
    }
I have a field in a custom object named Closing Report which opens up a VF page with a list of addresses contained in another custom object. Now I want as soon as any address is selected, the address fields of Closing Report to be auto populated. How to achieve this? Please help me
with the class User-added image
Following is the class.Can someone help me with the Test class for the same

global class AP88_DailyBatchesReportScheduler implements Schedulable{
    
    global void execute(SchedulableContext sc){
        Messaging.SingleEmailMessage email = Utils_Methods_Batch.generateBatchReport(null);
        email.setToAddresses((
            (String)Integration_Settings__c.getInstance()
            .get('Support_team_emails__c')).split(';'));
        Messaging.sendEmail(new List<Messaging.Email> {email});      
    }
}
I have the following method which opens a new record page from a VF page. "Account" is a lookup field in the record page which has to be populated from the TR1__Account__c field in the Closing Report object. How do I achieve this? Here is the method I wrote.
public PageReference create() {
        id = ApexPages.currentPage().getParameters().get('id');
           cr = [Select TR1__Account__c from TR1__Closing_Report__c where Id =: id];
        accountId = cr.TR1__Account__c;
        PageReference pageRef = new PageReference('https://foiberia--devv11.cs88.my.salesforce.com/a2w/e?retURL=%2Fa2w%2Fo');
        pageRef.getParameters().put('Account',String.valueOf(accountId));
        return pageRef.setRedirect(true);
    }