Friday, 22 January 2016

salesforce interview questions and answers for experienced

  • Pictorial representation of internet is Cloud.
  • Cloud Computing is nothing but internet computing.
  • With this approach everything can be done in internet (Using Application, Developing Application and distributing the hardware), no need of any minimum hardware requirements and no need to install any software in local system.
  • Cloud Computing is an approach to provide the following services -
    1. SAAS (Software As A Service)
    2. PAAS (Platform As A Service)
    3. IAAS (Infrastructure As AService)             
      1. Salesforce is a company which provides a web based tool called Salesforce
      2. Salesforce by following the Cloud Computing approach, providing SAAS and PAAS
      3. SAAS: Providing Sales, Marketing and Call Center applications as a service
      4. PAAS: Providing Force.com platform in which we can develop Apex (Programming language similar to Core Java) and Visualforce (Mark up language similar to HTML) logic
        1. Number of DML statements per transaction: 150 (as a whole including insert, update, delete and undelete)
        2. Number of rows processed per DML stmt: 10000 
        3. Name three Governor Limits.
        4. When do you use a before vs. after trigger?
        5. What’s the maximum batch size in a single trigger execution?
        6. What are the differences between 15 and 18 digit record IDs?
        7. Provide an example of when a Custom Setting would be used during development.
        8. When should you build solutions declaratively instead of with code?
        9. Give an example of a standard object that’s also junction object.
        10. Describe a use case when you’d control permissions through each of the following:
          – Profiles
          – Roles
          – Permission Sets
          – Sharing Rules
        11. When should an org consider using Record Types?
        12. What are some use cases for using the Schema class?
        13. A trigger is running multiple times during a single save event in an org. How can this be prevented?
        14. Why is it necessary for most sales teams to use both Leads and Contacts?
        15. What is the System.assert method and when is it commonly used?
        16. What are the differences between SOQL and SOSL?
        17. Order the following events after a record is saved:
          – Validation rules are run
          – Workflows are executed
          – “Before” triggers are executed
          – “After” triggers are executed
        18. What is Trigger.old and when do you normally use it?
        19. When should you use a lookup instead of a master-detail relationship?
        20. What are the advantages of using Batch Apex instead of a trigger?
        21. What are the pros and cons when using a Workflow Rule Field Update vs. a Formula Field?
        22. What are the differences between a Map and a List?
        23. What are the advantages of using Batch Apex instead of a trigger?
        24. Describe a use case for Static Resources.
        25. Provide an example of when a Matrix report would be used. How about a Joined report?
        26. A group of users must be prevented from updating a custom field. What’s the most secure method of preventing this?
        27. When would you use the @future annotation?
        28. List three different tools that can be used when deploying code.
        29. When should an Extension be used instead of a Custom Controller?
        30. What are the advantages of using External Id fields?
        31. What are the uses of the <apex:actionFunction> tag?
        32. What are the differences between static and non-static variables in Apex?
        33. What are some best practices when writing test classes?
        34. What does the View State represent in a Visualforce page?
        35. What are three new features in the most recent Salesforce release?
        36. Describe the benefits of the “One Trigger per Object” design pattern.
        37. Write a SOQL query that counts the number of active Contacts for each Account in a set.
        38. Declaratively create logic in your org that prevents two Opportunities from being created on a single Account in a single day.
        39. Declaratively create logic in your org that prevents closed Opportunities from being updated by a non System Administrator profile.

Wednesday, 30 April 2014

RecordshareToUser using Apex and vfpage in salesforce.com

For This Need to create one Job Object


vfpage
----------------------------------
<apex:page standardController="Job__c"   extensions="RecordshareToUserApexCon">
    <apex:form >
      <apex:pageBlock >
     
                <apex:selectList size="1" value="{!jobst }" multiselect="false">
                    <apex:selectOptions value="{!Job}"> </apex:selectOptions> 
                     <apex:actionSupport event="onchange" reRender="table,opt1" />
                </apex:selectList>
    
                <apex:selectList size="1" value="{!selectedVal}" multiselect="false">
                <apex:actionSupport event="onchange" reRender="table,opt1" />
                    <apex:selectOptions value="{!Value}">
                    </apex:selectOptions>
                </apex:selectList>
               
                <apex:outputText id="opt12" value="{!selectedVal}"></apex:outputText>
               
               <apex:commandLink action="{!manualShareRead}" value="Share" id="opt1">
                </apex:commandLink>
       </apex:pageBlock>
           
     </apex:form>
</apex:page>
--------------------------------------------------------------------------
apex page
-----------------------------------------------------------------------------
public class RecordshareToUserApexCon
 {   
         List<user> con1= new List<user>(); 
         public job__c j {get;set;}
         Public List<string> usertselect{get;set;}
         public string jobst { get;set;}
         public string val{ get;set;}
         public user gp {get;set;}
         public boolean nojb{get;set;}
         public String selectedVal{get;set;}
         public List<job__C> joblist = new List<job__C>();
        
         public RecordshareToUserApexCon () {

          }
         public RecordshareToUserApexCon (ApexPages.StandardController controller) {
          }
       
   

           public List<SelectOption> getJob(){  
       
             List<SelectOption> option = new List<SelectOption>();
             
            for(job__c j: [Select id,name From  job__c]){
             
                     option.add(new SelectOption(j.name,j.name));
                     system.debug('option value is '+option);
                    
                 }
                 return option;     
           }
             public List<SelectOption> getValue(){  
            
                 List<SelectOption> option = new List<SelectOption>();
                     
                for(user gp: [Select id,name From  user  ])
                 {
                 
                     option.add(new SelectOption(gp.name,gp.name));
                     system.debug('option value is '+option);
                    
                 }
                 return option;     
             }
                
       public PageReference manualShareRead() {
             
                 
                   joblist = [select id from job__C where name=:jobst];
                   con1 = [select id from user where name=:selectedVal];
                   system.debug('PGList value is'+con1);
                   system.debug('PGList value is'+joblist);
                   Job__Share jobShr  = new Job__Share(); 
                   jobShr.ParentId = joblist[0].id;
                   jobShr.UserOrGroupId = con1[0].id;
                   jobShr.AccessLevel = 'Read';
                   jobShr.RowCause = Schema.Job__Share.RowCause.Manual;
                  
                 Database.SaveResult sr = Database.insert(jobShr,false);
                  system.debug('sr value is'+sr);
          
                 if(sr.isSuccess()){
                   system.debug('sr.isSuccess() value:'+sr.isSuccess());
                      system.debug('if sr.isSuccess() block');
                   PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                 
                    return nextpage;
                   }
               else {
                      system.debug('inner else sr.isSuccess() block');
                         Database.Error err = sr.getErrors()[0];
                         if(err.getStatusCode() == StatusCode.FIELD_FILTER_VALIDATION_EXCEPTION  && 
                         err.getMessage().contains('AccessLevel')){
                          system.debug(' iner if sr.isSuccess() block');
                          PageReference nextpage = new PageReference('/apex/CustomTeam?id='+joblist[0].id);
                    return nextpage;
                }
                 else{
                          system.debug('outer else sr.isSuccess() block');
                   PageReference nextpage = new PageReference('/apex/RecordShareFailure?id='+joblist[0].id);
                        return nextpage;
                   }
                 }
                
                
           
         
         }
  
  
       
     }


Encrypt and Decrypt in salesforce using apex and vf page


<apex:page standardController="EnCrypt_Decrypt__c" extensions="EncryptExtensioncls">
    <apex:form >
        <apex:pageBlock >
            <apex:pageBlockSection >
                <apex:inputField value="{!encrypt.Name}"/>
                <apex:commandButton value="Save" action="{!Save}"/>
                <apex:commandButton value="Update" action="{!test}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

-------------

public class EncryptExtensioncls{
    public EnCrypt_Decrypt__c encrypt{get;set;}
    
    //Blob cryptoKey;
    Blob cryptoKey = Blob.valueOf('51266ysaj6671678');
   
    public Id recordId{get;set;}
    public EncryptExtensioncls(ApexPages.StandardController controller) {
        //cryptoKey = Crypto.generateAesKey(256);
        recordId = Apexpages.CurrentPage().getParameters().get('id');
        if(recordId !=null){
            encrypt = [SELECT id,Name From EnCrypt_Decrypt__c
                    WHERE id=:recordId];
           
        }
        else{
            encrypt = new EnCrypt_Decrypt__c();
          
        }
    }
   
    public PageReference Save(){
        
         Blob data = Blob.valueOf(encrypt.Name);
         Blob encryptedData = Crypto.encryptWithManagedIV('AES128', cryptoKey , data );
        
         String b64Data = EncodingUtil.base64Encode(encryptedData);
        
         encrypt.name = b64Data ;
        
        
         insert encrypt;
        
         return null;
    }
    public PageReference test(){
        
         //Blob cryptoKey = Crypto.generateAesKey(256);
         //Blob data = Blob.valueOf(encrypt.Name);
         Blob data = EncodingUtil.base64Decode(encrypt.Name);
        
         Blob decryptedData = Crypto.decryptWithManagedIV('AES128', cryptoKey , data);
        
         String dryptData = decryptedData.toString();
        
         System.debug('Printing dryptData '+dryptData);
        
        
         encrypt.name = dryptData;
               
        
         update encrypt;
        
         return null;
    }
}

customize omni channel logic to distribute cases based on Case Creation Date

Omni Channel queues distributes cases, based on Date/Time the case is assigned to the queue. we can customize this logic to look for some ...