• Sakthidasan
  • NEWBIE
  • 110 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 16
    Questions
  • 11
    Replies
Can you explain?How can the call is made.Account is a class? what's the relationship between Account.sObjectType
By default  primary keys, forgeign keys, custom fields marked as External Ids/Unique along with the system dates (like last modified) are indexed.but you we need index?it it useful for reterive large record,Please explain
I read the Hierarchy Custom Settings in document.As I understand.The hierarchy logic checks the organization, profile, and user settings for the current user and returns the most specific, or “lowest,”� value.Please explain.what it  return (specific or lowest value means)?.please give real time example
 
I'm learning vf page.I am struggling display a record from vg page.I copy the id of the contact record and past in url like same(https://***Salesforce_instance***/apex/HelloWorld2?id=001D000000IRt53) but I'm not see the record in vf page.my code here:

<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock title="Quick Edit: {!Contact.Name}">
<apex:pageBlockSection title="Contact Details" columns="1">
<apex:inputField value="{!Contact.Phone}"/>
<apex:outputField value="{!Contact.MobilePhone}"
label="Mobile #"/>
<apex:inputText value="{!Contact.Email}"
label="{!Contact.FirstName + '’s Email'}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
we handle recursive via static boolean variable.but my question is why should we use static boolean variable.instead of object variable(as i understand static is a class variable.we can call directly by class name no object is require) 
 would like to know that where's this Owner coming from? I don't see there's a Owner object and I believe that Owner.Name was getting from User object.when should we use owner field ?
I'm learing trigger concept throuth apex documentation.but I can't understand follwoing point.please explain 
​Triggers can also modify other records of the same type as the records that initially fired the trigger. For example, if a trigger fires after
an update of contact A, the trigger can also modify contacts B, C, and D. Because triggers can cause other records to change, and
because these changes can, in turn, fire more triggers, the Apex runtime engine considers all such operations a single unit of work and
sets limits on the number of operations that can be performed to prevent infinite recursion
I'm leanring dynamic apex.it can be useful for create flexible application.but when we should we use dynamic apex.please explain real time example
I'm new to salesforce please clarify my doubt about outbound message,As I understand outbound message is part of work flow rule and it can be useful for sending on message to external service.what situation we should use outbound message.please give real time example
 
Batch class as exposed as interface implement by developer.it is helpful for handle large number of records.Please explain real time exmple why we need to use Batch class  in real time?
why we need to use action support  in visualforce page in real time? what is the need of using action support? 
I'm new to salesforce.How to write test class for follwing Apex class.it function is get unique ownerId from the object 
 and find out sum of outcome,howmany event occur in the current month and send the email to the owner.
Apex class:
public class oppOwnerOutcome {
    //Remove debug statements
    public void executeLogic(){
        Map<String,List<Meeting__c>> outCmeMap=new Map<String,List<Meeting__c>>();
        Map<String,Decimal> ownerOutComeMap =new Map<String,Decimal>();
        Map<String,String> ownerNameMap =new Map<String,String>();
        Map<String,String> ownerEmailMap =new Map<String,String>(); 
        Set<Id> ownerIdSet = new Set<Id>();     
        for(Meeting__c mData:[SELECT id, OutCome__c, Expected_Close_Date__c, AccountMaster__r.Ownerid, AccountMaster__r.Owner.Name FROM Meeting__c WHERE OutCome_Flag__c = false AND Expected_Close_Date__c = THIS_MONTH]){         
            if(!outCmeMap.containsKey(mData.AccountMaster__r.Owner.id)){                
                List<Meeting__c> meetingList=new List<Meeting__c>();
                meetingList.add(mData);
                outCmeMap.put(mData.AccountMaster__r.Owner.id,meetingList);
            }
            else{
                List<Meeting__c> meetingList=new List<Meeting__c>();
                //Use OwnerId
                meetingList=outCmeMap.get(mData.AccountMaster__r.Owner.id);
                meetingList.add(mData);
                outCmeMap.put(mData.AccountMaster__r.Owner.id,meetingList);
            }
        }
        for(String owrId:outCmeMap.keySet()){
            Decimal totalOutcomePerOwner = 0;
            for(Meeting__c mtg: outCmeMap.get(owrId)){
                totalOutcomePerOwner = mtg.OutCome__c+totalOutcomePerOwner ;
                //System.debug('summary'+res1.OutCome__c);              
            }
            ownerOutComeMap.put(owrId, totalOutComePerOwner);
        }
        
        List<User> owRecList = new List<User>();
        owRecList = [SELECT Id, Name, Email FROM User WHERE Id IN: outCmeMap.keySet()];
        for(User uRec:owRecList){
            ownerNameMap.put(uRec.Id, uRec.Name);
            ownerEmailMap.put(uRec.Id, uRec.Email); 
        }       
        List<EmailObj__c> emailRecList = new List<EmailObj__c>();
        //Move hardcoded values to custom labels or settings
        for(String owrId:outCmeMap.keySet()){
            EmailObj__c emailRec = new EmailObj__c();
            emailRec.send_Address__c = ownerEmailMap.get(owrId);
            String emailBody = 'Dear '+ownerNameMap.get(owrId)+'<br></br>' +
                                'Total Opportunity Outcome expected for this month is '+ownerOutComeMap.get(owrId)+'<br></br>' +
                                'Regards'+'<br></br>' +
                                'Sales Team';
            emailRec.emailBody__c = emailBody;
            emailRecList.add(emailRec);
        }
        //Use database.insert instead of insert statement
        //database.saveResult[] srList = database.insert(emailRecList, false);
        //for(Database.saveResult sr : srList) {
   
        insert emailRecList;
        
        //System.debug('summary:'+summary);
    }         
}
Apex Test Class:
@isTest
private class oppOwnerOutcomeTest {
    
    static  testMethod void testoutCome(){
        
         Account acc=new Account(Name='TestMethod');
        insert acc;
        
        Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp;
        Opportunity opp1=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp1;
        
        Meeting__c mRec = new Meeting__c( AccountMaster__c = acc.id, OutCome_Flag__c = false );
        insert mRec ;
        Meeting__c mRec1 = new Meeting__c( AccountMaster__c = acc.id, OutCome_Flag__c = false );
        insert mRec1 ;
        oppOwnerOutcome tt=new oppOwnerOutcome();
        tt.executeLogic();
        
    }

}
I create atfter update trigger on Account object.it takes all the contacts from account object and update the contact mailing Address,I create another after update trigger on Contact object.it monitor the last contact update.I got recursive .my question is ,what kind of situation recursive trigger occurs,why we use static lock.static lock use for both trigger ?or any one ?
here my code:

trigger AccountRecursiveTrigger on Account (after insert,after update) {
    if(checkRecursive.isFutureUpdate) {
        checkRecursive.isFutureUpdate=false;
    List<Contact> updateContact=new List<Contact>();
    List<Account> accounts=new List<Account>();
    accounts=[select id,Name,BillingStreet,BillingCity,BillingCountry,
              (select id,FirstName,LastName,MailingStreet,MailingCity,MailingCountry from Contacts) from Account where id IN:trigger.new];
    system.debug('cc::'+accounts);
    for(Account acc:accounts){
        for(Contact con:acc.Contacts){
            
             con.MailingStreet=acc.BillingStreet;
             con.MailingCity=acc.BillingCity;
            con.MailingCountry=acc.BillingCountry;
            updateContact.add(con);
            
        }
        
    }
             
    update updateContact;
     
         
    }
}

trigger ContactRecursiveTrigger on Contact (after insert,after update) {
     System.debug('afterif::'+checkRecursive.isFutureUpdate);
    //if(checkRecursive.isFutureUpdate=true) {
        System.debug('afterif::'+checkRecursive.isFutureUpdate);
    Map<id,Account> updateAccount=new Map<id,Account>();
    for(Contact con:trigger.new){
        if(con.AccountId !=null){
            
            Account acc=new Account(id=con.AccountId,Contact_Last_Updates__c=system.now());
            updateAccount.put(con.AccountId, acc);
        }
        
    }
    System.debug('valuess:'+updateAccount.values());
       // checkRecursive.isFutureUpdate=false;
    update updateAccount.values();
         System.debug('change::'+checkRecursive.isFutureUpdate);
        
//}
}
 
In the document I can't understand.(The only time it is necessary to refer to a StandardController object is when defining an extension for a standard controller. StandardController is the data type of the single argument in the extension class constructor.)
can you explain this code.
what will I get?
ApexPages.StandardController sc = new ApexPages.StandardController(Account);
I'm new to salesforce any one please explani how to write test class for extension controller class.In the vf page I show the account details and custom object details.If the user not staisfied the result .they create case and task based on the scenerio I create one extension controller.
here is my Controlle Code:
public class MeetingOverviewExtension {
    public final Account accRec;
    public String issueRadio {get; set;}
    transient public Integer counts {get; set;}
    //public List<Meeting__c> meetingList=new List<Meeting__c>();
     public List<Meeting__c> meetingList {get; set; }
   
    public MeetingOverviewExtension(ApexPages.StandardController controller){
        accRec = (Account)controller.getRecord();
        meetingList=[select id,StartDate__c,EndDate__c,Expected_Close_Date__c,Location__c,
                    Purpose__c,OutCome__c from Meeting__c where AccountMaster__c=: accRec.id];
        system.debug('check'+meetingList.size());
        
       
             counts = (Integer) [select count() from meeting__c where AccountMaster__c=: accRec.id and Expected_Close_Date__c = THIS_MONTH];
        System.debug('outttt'+counts);
    }
    public PageReference submit(){
         Task T = new Task();
         Case cRec=new Case();
        if(issueRadio == 'Yes'){
            system.debug('yesstruee');
       
        T.Type = 'Email';
                 T.Description = 'Reassign the outcome'; 
                T.Subject='Outcome monitoring';
    T.WhatId = accRec.Id; 
           
            cRec.Status='New';
            cRec.Status='Email';
            cRec.AccountId=accRec.Id;
     
            }
        try{
            insert T;
            insert cRec;
            system.debug('Caseid::'+cRec.id);
        }
        catch(System.DmlException e){
            System.debug(e.getMessage());
            return null;
                
        }

          PageReference page = new PageReference('/'+accRec.Id);
        page.setRedirect(true);
        return page;

            }
  
}
Test Class:
@isTest 
public class MeetingOverviewExtensionTest {
    
    static testMethod void testMethod1(){
        
        Account acc=new Account(Name='TestMethod');
         insert acc;
         Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
             insert opp;
         Meeting__c mRec=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false);
         insert mRec;
        ApexPages.StandardController sc = new ApexPages.StandardController(acc);
       // sc.setSelected(acc);
        MeetingOverviewExtension testAccPlan = new MeetingOverviewExtension(sc);
        
         Task T = new Task();
        T.Type = 'Email';
                 T.Description = 'Reassign the outcome'; 
                T.Subject='Outcome monitoring';
                    T.WhatId = acc.Id; 
        insert T;
         PageReference pageRef = Page.MeetingOverviewForm;
       // Test.setCurrentPage(pageRef);
          pageRef.getParameters().put('id', String.valueOf(acc.Id));
        Test.setCurrentPage(pageRef);
    
    }
}
I'm new to salesfore I wrote test class for after update scnerio but I got only 72 code coverage.How do get 100% coverage.here's my trigger
and the test class.
TriggerHandler Class:
public  class OpportunityTriggerHandler {
    
    public static void outComeDealProcess(List<Opportunity> NewOpps,Set<id> Opp){
        
    List<Meeting__c    > meetingRec=new List<Meeting__c    >();
    List<Meeting__c> meetingIdList=new List<Meeting__c>();
    meetingIdList=[select id,OpportunityLookup__c from Meeting__c where OpportunityLookup__c IN :Opp];
    
        for(Opportunity oppRec:NewOpps){
        
            if(oppRec.StageName=='Closed Won'|| oppRec.StageName=='Closed Lost'){
                for(Meeting__c mRec:meetingIdList){
         
                if(oppRec.Id==mRec.OpportunityLookup__c)
                    mRec.OutCome_Flag__c=false;
                    meetingRec.add(mRec);
                }
            }
    }
update meetingRec;
    
    }
    
}
Test class:
@isTest
private class OpportunityTriggerHandlerTest {
    @isTest 
    public static void testocc(){
         Account acc=new Account(Name='TestMethod');
         insert acc;
        Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
         Opportunity opp1=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp;
         Meeting__c mRec=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false);
         insert mRec;
         Meeting__c mRec1=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false,OpportunityLookup__c=opp.id);
      
        opp.StageName='Closed Won';
        update opp;
        
       
     }
    
}
I'm learning vf page.I am struggling display a record from vg page.I copy the id of the contact record and past in url like same(https://***Salesforce_instance***/apex/HelloWorld2?id=001D000000IRt53) but I'm not see the record in vf page.my code here:

<apex:page standardController="Contact">
<apex:form >
<apex:pageBlock title="Quick Edit: {!Contact.Name}">
<apex:pageBlockSection title="Contact Details" columns="1">
<apex:inputField value="{!Contact.Phone}"/>
<apex:outputField value="{!Contact.MobilePhone}"
label="Mobile #"/>
<apex:inputText value="{!Contact.Email}"
label="{!Contact.FirstName + '’s Email'}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
 would like to know that where's this Owner coming from? I don't see there's a Owner object and I believe that Owner.Name was getting from User object.when should we use owner field ?
I'm leanring dynamic apex.it can be useful for create flexible application.but when we should we use dynamic apex.please explain real time example
I'm new to salesforce.How to write test class for follwing Apex class.it function is get unique ownerId from the object 
 and find out sum of outcome,howmany event occur in the current month and send the email to the owner.
Apex class:
public class oppOwnerOutcome {
    //Remove debug statements
    public void executeLogic(){
        Map<String,List<Meeting__c>> outCmeMap=new Map<String,List<Meeting__c>>();
        Map<String,Decimal> ownerOutComeMap =new Map<String,Decimal>();
        Map<String,String> ownerNameMap =new Map<String,String>();
        Map<String,String> ownerEmailMap =new Map<String,String>(); 
        Set<Id> ownerIdSet = new Set<Id>();     
        for(Meeting__c mData:[SELECT id, OutCome__c, Expected_Close_Date__c, AccountMaster__r.Ownerid, AccountMaster__r.Owner.Name FROM Meeting__c WHERE OutCome_Flag__c = false AND Expected_Close_Date__c = THIS_MONTH]){         
            if(!outCmeMap.containsKey(mData.AccountMaster__r.Owner.id)){                
                List<Meeting__c> meetingList=new List<Meeting__c>();
                meetingList.add(mData);
                outCmeMap.put(mData.AccountMaster__r.Owner.id,meetingList);
            }
            else{
                List<Meeting__c> meetingList=new List<Meeting__c>();
                //Use OwnerId
                meetingList=outCmeMap.get(mData.AccountMaster__r.Owner.id);
                meetingList.add(mData);
                outCmeMap.put(mData.AccountMaster__r.Owner.id,meetingList);
            }
        }
        for(String owrId:outCmeMap.keySet()){
            Decimal totalOutcomePerOwner = 0;
            for(Meeting__c mtg: outCmeMap.get(owrId)){
                totalOutcomePerOwner = mtg.OutCome__c+totalOutcomePerOwner ;
                //System.debug('summary'+res1.OutCome__c);              
            }
            ownerOutComeMap.put(owrId, totalOutComePerOwner);
        }
        
        List<User> owRecList = new List<User>();
        owRecList = [SELECT Id, Name, Email FROM User WHERE Id IN: outCmeMap.keySet()];
        for(User uRec:owRecList){
            ownerNameMap.put(uRec.Id, uRec.Name);
            ownerEmailMap.put(uRec.Id, uRec.Email); 
        }       
        List<EmailObj__c> emailRecList = new List<EmailObj__c>();
        //Move hardcoded values to custom labels or settings
        for(String owrId:outCmeMap.keySet()){
            EmailObj__c emailRec = new EmailObj__c();
            emailRec.send_Address__c = ownerEmailMap.get(owrId);
            String emailBody = 'Dear '+ownerNameMap.get(owrId)+'<br></br>' +
                                'Total Opportunity Outcome expected for this month is '+ownerOutComeMap.get(owrId)+'<br></br>' +
                                'Regards'+'<br></br>' +
                                'Sales Team';
            emailRec.emailBody__c = emailBody;
            emailRecList.add(emailRec);
        }
        //Use database.insert instead of insert statement
        //database.saveResult[] srList = database.insert(emailRecList, false);
        //for(Database.saveResult sr : srList) {
   
        insert emailRecList;
        
        //System.debug('summary:'+summary);
    }         
}
Apex Test Class:
@isTest
private class oppOwnerOutcomeTest {
    
    static  testMethod void testoutCome(){
        
         Account acc=new Account(Name='TestMethod');
        insert acc;
        
        Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp;
        Opportunity opp1=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp1;
        
        Meeting__c mRec = new Meeting__c( AccountMaster__c = acc.id, OutCome_Flag__c = false );
        insert mRec ;
        Meeting__c mRec1 = new Meeting__c( AccountMaster__c = acc.id, OutCome_Flag__c = false );
        insert mRec1 ;
        oppOwnerOutcome tt=new oppOwnerOutcome();
        tt.executeLogic();
        
    }

}
I'm new to salesforce any one please explani how to write test class for extension controller class.In the vf page I show the account details and custom object details.If the user not staisfied the result .they create case and task based on the scenerio I create one extension controller.
here is my Controlle Code:
public class MeetingOverviewExtension {
    public final Account accRec;
    public String issueRadio {get; set;}
    transient public Integer counts {get; set;}
    //public List<Meeting__c> meetingList=new List<Meeting__c>();
     public List<Meeting__c> meetingList {get; set; }
   
    public MeetingOverviewExtension(ApexPages.StandardController controller){
        accRec = (Account)controller.getRecord();
        meetingList=[select id,StartDate__c,EndDate__c,Expected_Close_Date__c,Location__c,
                    Purpose__c,OutCome__c from Meeting__c where AccountMaster__c=: accRec.id];
        system.debug('check'+meetingList.size());
        
       
             counts = (Integer) [select count() from meeting__c where AccountMaster__c=: accRec.id and Expected_Close_Date__c = THIS_MONTH];
        System.debug('outttt'+counts);
    }
    public PageReference submit(){
         Task T = new Task();
         Case cRec=new Case();
        if(issueRadio == 'Yes'){
            system.debug('yesstruee');
       
        T.Type = 'Email';
                 T.Description = 'Reassign the outcome'; 
                T.Subject='Outcome monitoring';
    T.WhatId = accRec.Id; 
           
            cRec.Status='New';
            cRec.Status='Email';
            cRec.AccountId=accRec.Id;
     
            }
        try{
            insert T;
            insert cRec;
            system.debug('Caseid::'+cRec.id);
        }
        catch(System.DmlException e){
            System.debug(e.getMessage());
            return null;
                
        }

          PageReference page = new PageReference('/'+accRec.Id);
        page.setRedirect(true);
        return page;

            }
  
}
Test Class:
@isTest 
public class MeetingOverviewExtensionTest {
    
    static testMethod void testMethod1(){
        
        Account acc=new Account(Name='TestMethod');
         insert acc;
         Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
             insert opp;
         Meeting__c mRec=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false);
         insert mRec;
        ApexPages.StandardController sc = new ApexPages.StandardController(acc);
       // sc.setSelected(acc);
        MeetingOverviewExtension testAccPlan = new MeetingOverviewExtension(sc);
        
         Task T = new Task();
        T.Type = 'Email';
                 T.Description = 'Reassign the outcome'; 
                T.Subject='Outcome monitoring';
                    T.WhatId = acc.Id; 
        insert T;
         PageReference pageRef = Page.MeetingOverviewForm;
       // Test.setCurrentPage(pageRef);
          pageRef.getParameters().put('id', String.valueOf(acc.Id));
        Test.setCurrentPage(pageRef);
    
    }
}
I'm new to salesfore I wrote test class for after update scnerio but I got only 72 code coverage.How do get 100% coverage.here's my trigger
and the test class.
TriggerHandler Class:
public  class OpportunityTriggerHandler {
    
    public static void outComeDealProcess(List<Opportunity> NewOpps,Set<id> Opp){
        
    List<Meeting__c    > meetingRec=new List<Meeting__c    >();
    List<Meeting__c> meetingIdList=new List<Meeting__c>();
    meetingIdList=[select id,OpportunityLookup__c from Meeting__c where OpportunityLookup__c IN :Opp];
    
        for(Opportunity oppRec:NewOpps){
        
            if(oppRec.StageName=='Closed Won'|| oppRec.StageName=='Closed Lost'){
                for(Meeting__c mRec:meetingIdList){
         
                if(oppRec.Id==mRec.OpportunityLookup__c)
                    mRec.OutCome_Flag__c=false;
                    meetingRec.add(mRec);
                }
            }
    }
update meetingRec;
    
    }
    
}
Test class:
@isTest
private class OpportunityTriggerHandlerTest {
    @isTest 
    public static void testocc(){
         Account acc=new Account(Name='TestMethod');
         insert acc;
        Opportunity opp=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
         Opportunity opp1=new Opportunity(Name='TestCaseOpp',StageName='Prospecting',CloseDate=system.today());
        insert opp;
         Meeting__c mRec=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false);
         insert mRec;
         Meeting__c mRec1=new Meeting__c(AccountMaster__c=acc.id,OutCome_Flag__c=false,OpportunityLookup__c=opp.id);
      
        opp.StageName='Closed Won';
        update opp;
        
       
     }
    
}