Sunday 18 December 2016

Salesforce Advanced Interview Questions

           Salesforce Advanced Interview Questions 


1.write sample trigger to update Account phone on its related contacts.


TriggerName: AccountHandlerTrigger


trigger AccountTriggerHandler on Account (after update) {

AccountHandlerClass.updateContacts2(Trigger.newMap);
}



/*******************************************************************
Class Name: AccountHandlerClass

Purpose:    1. This is the Trigger Handler class for Account object




public class AccountHandlerClass {

/*******  Sample method 1 *********/

 public static void updateContacts2(map<id,account> newAccountMap){
   
list<contact> lstCons =[select id,name,phone,Accountid from contact where Accountid in :newAccountMap.keySet()];
system.debug('lstCons :'+lstCons);
list<contact> updCons = new list<contact>();
if(!lstCons.isEmpty()){
for(contact c : lstCons){
if(c.Phone != newAccountMap.get(c.AccountId).phone){
c.Phone = newAccountMap.get(c.AccountId).phone;
updCons.add(c);
}
}
}
   update updCons;
}

}


2.write Soql query to Accounts with contact. 

list<account> acc = [select Id,name from Account where Id In (select AccountId from Contact)];

system.debug('acc : '+acc.size());



3.if a controller has a series of extensions then which extension will execute first.




If both extension having same method, whichever methods are defined in the “leftmost” extension, or, the extension that is first in the comma-separated list will execute first.


====================================================================
<apex:page standardController="Account" extensions="Extension1,Extension2">
    <apex:form>
        Displaying name from Extensions : "{!Name}"
    
    </apex:form>
</apex:page>
====================================================================
public class Extension1 {    
    public Extension1(ApexPages.StandardController controller){}
    public static string getName(){      
        return 'Prasad';
    }

}



public class Extension2 {      
    public Extension2(ApexPages.StandardController controller){}
  
    public static string getName(){       
        return 'Kalyan';
    }
    
}


=======================================================================
4.Transaction Control using SavePoint and Rollback in Salesforce.

SavePoint and Rollback will help us to maintain transaction for DML statement.
Suppose you  have written multiple lines of DML statements in a try block, If any error occurs during DML Operations, the operation will be rolled back to the most recent save point and the entire transaction will not be aborted.

   Savepoint sp;
try{
   sp = Database.setSavepoint();
  
   Account a = new Account();
   a.Name = 'Test Account';
   insert a;
  
   Contact c = new Contact(Account = a.Id);
   c.FirstName = 'Biswajeet';
   c.LastName = 'Samal';
   insert c;
  }
catch(Exception e){
    Database.RollBack(sp);
}

More Info : 


5.can we do a Callout from with in a Trigger ?



6.How to get Custom Settings in Apex Test code?


@isTest
public class BIIB_testClassHelper{

/*
 * Creating custom settings data in creation in test class .
 *  Avoid @isTest(SeeAllData = True) in test classes..
 */

public static testMethod void customsettingcreation(){
  
Id SampleRecordtypeID=Schema.SObjectType.Case.getRecordtypeinfosbyname().get('Recordtype Name').getRecordtypeId();
string Country = 'USA';

Custom_Settings__c cusutomsetting = new Custom_Settings__c();
cusutomsetting.RecordType_ID__c=SampleRecordtypeID;
cusutomsetting.CountryName__c=Country;

insert cusutomsetting;

   }
}



8.Trigger to update All contact names in Account Field.

===================================================================
trigger ContactTrigger_Handler on Contact (after insert,after delete) {
    
    if(trigger.isinsert && trigger.isAfter){
        updaetcontactnamefield.updateaccount(Trigger.new);
    }
    
     if(trigger.isdelete && trigger.isAfter){
        updaetcontactnamefield.updateaccount(Trigger.old);
    }

}

====================================================================
public class updaetcontactnamefield{
    public static void updateaccount(list<contact> contacts){
        set<id> accountIds = new set<id>();
        
        if(!contacts.isEmpty()){
            for(contact c:contacts){
                accountIds.add(c.accountid);
            }
        }
        
        list<account> lstAcc = new list<account>();
        for(Account acc : [Select id, name, description, 
                           (Select Id, name, LastName From Contacts) 
                           From Account Where Id In : accountIds])
        {
            List<String> lstSrting = new List<String>();
            for(Contact con : acc.contacts)
            {
                lstSrting.add(con.lastname);
            }
            acc.description = String.join(lstSrting, ',');
            lstAcc.add(acc);
        }
      update lstAcc;
    }
    
}

====================================================================

9.How to setup Field Level Security (FLS) for Person Account Fields.

OR
Why I am not able to find list of Person Account fields in Field Level Security (FLS) settings when navigated to fields on Account Object.
Ans :


Field Level Security (FLS) of Person Account fields ar controlled by Contact Fields. So, if you want to setup FLS of Person Account Fields navigate to fields of Contact and it will be reflected on Person Account.

10.In below code snippet , What is your observation and what is going wrong ?


trigger TestBeforeDelete on Lead (before Delete) {

for(Lead l : Trigger.Old)
{
l.addError('error');
}

String msgBody = 'Test Email';
String Subject = 'Test from Cogni Force on Lead';
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[] {'abc@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('abc@gmail.com');
mail.setSenderDisplayName('Cogniforce Test Simulator');
mail.setSubject(Subject);
mail.setPlainTextBody(msgBody);
mail.setHTMLBody(msgBody);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
Ans :
It will not send any email. Because “adderror” prevents all transactions from committing including emails.

10.How To Start Loading Data From 101 Row Of The CSV File In Data Loader?


In Dataloader Settings we need to specify Start Row no:

11.Calling future method from batch class?


Future method cant be called from future or Batch.


recommend the use of System.Queueable call instead of @Future. You can create a class that is constructed with any kind of argument that you want to hand in, like so:
public class DeferredHandler implements System.Queueable{
    public void execute(System.QueueableContext objContext)    {
        //do your @Future stuff here 
    }
}
And invoke him from inside your batch like this:
//defer stuff
System.Queueable job = new DeferredHandler(key2val);
System.enqueueJob(job);


12.How we can display serial-nos in standardlistcontroller.

<apex:page standardController="Account" recordSetVar="accounts" tabstyle="account" sidebar="false">
  <apex:pageBlock >
      <apex:variable var="rowcount" value="{!0}" />      
    <apex:pageBlockTable value="{!accounts}" var="a" >
       <apex:column>
        {!rowcount} <apex:variable var="rowcount" value="{!rowcount+1}" />
    </apex:column>
      <apex:column value="{!a.name}"/>
      <apex:column value="{!a.phone}"/>
    </apex:pageBlockTable>
  </apex:pageBlock>

</apex:page>

Monday 5 December 2016

Salesforce Winter17 Developer Maintenance (401)

1.Which capability does the Lightning Mass Action feature allow beyond standard Actions?
A. Firing a single action on multiple objects at once.
B. Firing multiple actions on multiple objects at once.
C. Firing a single action on multiple records at once.
D. Firing multiple actions on multiple records at once.
2.What does the new ISCLONE function check when comparing two items?
A. If an item has the ability to be cloned.
B. If an item was cloned when created.
C. If one Item is a clone of another.
D. If an Item has ever been cloned.
3.Where is the exported template saved in an Org when using Lightning Bolt for Communities?
A. Community Brand Manager
B. Community Creation wizard
C. Installed Packages
D. Personal App Exchange
4.What must be shared between two objects to invoke one process from another using Process Builder?
A. Owner
B. Master-Detail
C. Junction Object
D. Unique ID
5.Which two pieces of information should be recorded on the Work Type object?
Choose 2 answers
A. The estimated complexity of a Task.
B. The skills recommended to complete a Task.
C. The list of activities to complete a Task.
D. The estimated duration of a Task.
E. The needed equipment to complete a Task


Salesforce Winter17 Administrator Maintenance (201)

1.Universal Containers’ sales reps use the Lightning Experience. They need to send quotes to their prospects. How can this be accomplished?
A. Create a quote from the product and email as a link.
B. Create a quote from the opportunity and email as a link.
C. Create a quote from the opportunity and email as a PDF.
D. Create a quote from the lead and email as a PDF.
2.Which three Chatter Feed functionalities are available in the lightning experience?
Choose 3 answers
A. Chatter comments automatically post without refresh.
B. Videos play directly in the Chatter feed.
C. Users can edit Chatter feed posts and comments.
D. Chatter Instant Messages without refresh.
E. Users can launch a Chatter Meeting directly from the feed.
3.Which two features are available in Partner Communities using the Customer Service template?
Choose 2 answers
A. Users can create their own list views.
B. Field level help displays to the user.
C. Report charts can be added to the layout.
D. Sales Path available for opportunities only.

4.The VP of Marketing at Universal Containers would like to track which campaigns led to opportunities. They would like to evenly attribute revenue across all campaigns that touched the opportunities. Which two tools should the administrator configure to meet the VP’s request?
Choose 2 answers
A. Create a custom campaign influence attribution model.
B. Add the Campaign Results section to the opportunity page layout and assign users the campaign influence permission so they can edit the fields.
C. Add the Influenced Opportunities related list to the campaign page layout and add the Campaign Influence to the opportunity page layout.
D. Clone the standard campaign influence model into a custom model.
E. Add the Influenced Opportunities related list to the opportunity page layout and add the Campaign Influence to the campaign page layout.

5.The sales manager at Universal Containers would like a dashboard component to list sales reps by opportunity pipeline amount with high and low values highlighted in different colors. With the Lightning Experience enabled, how should the system administrator configure the component to meet the sales manager’s need?
A. Create a metric component for each rep in descending order with conditional highlighting in Lightning.
B. Create a table component, conditional highlighting and sort the columns within Lightning.
C. Create a table component and sort the columns in Lightning. Add conditional highlighting in classic.
D. Create a table component, conditional highlighting in Lightning and sort the columns in classic.


Complete Salesforce CPQ training Free videos

Salesforcestart:: We are excited to announce that our YouTube channel, Salesforcestart, is your one-stop-shop for all things Salesforce CPQ!...