ads

Friday 24 March 2017

Get Object Name From Id Value In Salesforce

Get Object Name From Id Value In Salesforce




Id myId = 'a2P5C000000ERKK'; //SAlesforce 15 or 18 digit Id
String sObjName = myId.getSObjectType().getDescribe().getName();
System.debug(LoggingLevel.INFO, '===sObjName='+sObjName); 

Fetching Profile Id by Passing Profile Name From Utility Class





Utility Class:-


public class Utility{   
    
   private static Map<String, Id> profileIdByName = new Map<String, Id>();
    
   public static Id getProfileIdByName(String profileName) {
        
        if (!String.isBlank(profileName)) {
        
          if (profileIdByName.containsKey(profileName)) {
                return profileIdByName.get(profileName);
            }
         else{        
            for(Profile pfInstance:[SELECT Name,Id FROM profile
                                              WHERE Name='System Admin'
                                              OR Name='Read Only' 
                                              OR Name='Marketing User']){
                profileIdByName.put(pfInstance.Name,pfInstance.Id);            
            } 
            
            return profileIdByName.get(profileName);
          }               
       }
       
        return Null;
    } 
  }


Fetching Profile Id Using Profile Name by Map :-


if(ProfileId == Utility.getProfileIdByName('Marketing User')){

//Your Logic

}

Fetch Record Type Id Using Record Type Name



private static Id idCustomerInterctionRT  = Schema.SObjectType.Case.getRecordTypeInfosByName().get('System Administrator').getRecordTypeId();

Insert Multiple Records in List and Save Using List


Below Example explains how we can add multiple Account Records in AccountList and Insert
All of them.

Example 1:-


  List<Account> AccInsert = new List<Account>();
    
    for( Integer i=0;i<=10;i++){
        Account Acc = new Account();
        Acc.Name = 'Account'+'=='+ i ;
        AccInsert.add(Acc);
    }
    
    Insert AccInsert;


Example 2:-


    List<CaseShare> csShareList = new List<caseShare>();       
       
for(User usrInstance:[Select ID FROM USER WHERE ISACTIVE = TRUE AND ProfileId ='00e5C000000DeBi']){
     CaseShare csShare = new CaseShare();//this should be in for loop
            csShare.CaseId  ='5005C000001TPOD';
            csShare.UserOrGroupId = usrInstance.Id;
            csShare.CaseAccessLevel = 'edit';
           csShareList.add(csShare);
}
     
         Insert csShareList;

Apex Sharing on Selected Records Using Developer Console



Apex Sharing for Standard Case Object . For every Standard Object we need to append Share keyword. Like for case apex sharing object will be CaseShare


  List<Case> CasesList = [SELECT ID FROM Case];
    List<CaseShare> csShareList = new List<caseShare>();       

        for(Case csInstance:CasesList){ 
            
            for(User usrInstance:[Select ID FROM USER WHERE IsActive = TRUE AND ProfileId ='00e5C000000DeBi']){
                
                CaseShare csShare = new CaseShare();//this should be in for loop
                csShare.CaseId  =csInstance.Id;
                csShare.UserOrGroupId = usrInstance.Id;
                csShare.CaseAccessLevel = 'edit';
                csShareList.add(csShare);
            }
        }
    Insert csShareList;  

Apex Sharing In Trigger For multiple Users


Apex Sharing for Standard Case Object . For every Standard Object we need to append Share keyword. Like for case apex sharing object will be CaseShare



Trigger CaseTriggerShraring on Case (After insert){        
        List<CaseShare> csShareList = new List<caseShare>();       
        
        for(Case csInstance:Trigger.New){ 
            
            for(User usrInstance:[Select ID FROM USER WHERE IsActive = TRUE AND ProfileId ='00e5C0000uiuyu']){
                
                CaseShare csShare = new CaseShare();//this should be in for loop
                csShare.CaseId  =csInstance.Id;
                csShare.UserOrGroupId = usrInstance.Id;
                csShare.CaseAccessLevel = 'edit';
                csShareList.add(csShare);
            }
        }
        Insert csShareList;                        
    }

Fetch All Contact Under Account Using Map Instead of Child Query

Creating a Map that Provide respected Contacts when passing Account ids


Map<Id, List<Contact>> AccountIdVslistContacts = new Map<Id, List<Contact>>();

for(Contact ConInstance: [SELECT AccountId,Id FROM Conatact]) {
 if(AccountIdVslistContacts.containsKey(ConInstance.AccountId)) {
  List<Contact> Contacts = AccountIdVslistContacts.get(conInstance.AccountId);
  Contacts.add(ConInstance.Id);
  AccountIdVslistContacts.put(ConInstance.AccountId , Contacts);
 } else {
  AccountIdVslistContacts.put(ConInstance.AccountId, new List<Contact> { ConInstance });
 }
}



Now using that map in our code to do operation on Contacts


List<Account> AccountList = new List<Account>();
 AccountList = [SELECT Id FROM ACCOUNT LIMIT 100]; 

 for(Account AccInstace:AccountList){ 
     //One by one Account will Enter in Loop
    
       //We will Pass that Account Id in Map and get those Contact ids
      for(Contact conInstance:AccountIdVslistContacts.get(AccInstance.Id)){  

            //Do your logic on Each Contact one by one
       }
 }

Salesforce Certified Administrator – Winter ’17 Release Exam

Question 1:
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.

Answer:A,B,C

Question 2:
Which two features are available in Partner Communities using the Customer Service template?

Choose 2 answers

A.Field level help displays to the user.
B.Sales Path available for opportunities only.
C.Users can create their own list views.
D.Report charts can be added to the layout.

Answer:A,D

Question 3:
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 opportunity and email as a PDF.
B.Create a quote from the product and email as a link.
C.Create a quote from the opportunity and email as a link.
D.Create a quote from the lead and email as a PDF.

Answer: A


Question 4:
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 table component and sort the columns in Lightning. Add conditional highlighting in classic.
B.Create a table component, conditional highlighting and sort the columns within Lightning.
C.Create a metric component for each rep in descending order with conditional highlighting in Lightning.
D.Create a table component, conditional highlighting in Lightning and sort the columns in classic.

Answer: A

Question 5:
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.Add the Influenced Opportunities related list to the opportunity page layout and add the Campaign Influence to the campaign page layout.
B.Add the Influenced Opportunities related list to the campaign page layout and add the Campaign Influence to the opportunity page layout.
C.Create a custom campaign influence attribution model.
D.Add the Campaign Results section to the opportunity page layout and assign users the campaign influence permission so they can edit the fields.
E.Clone the standard campaign influence model into a custom model.

Answer:B,C

Salesforce Certified Platform App Builder - Winter '17 Release Exam

Question 1:
What component must be included in a change set in order to deploy a global picklist value set?

A.Global Value Set
B.Custom Field
C.Field Mapping
D.Picklist Values

Answer: A

Question 2:
 Which two options are available when activating a custom record page in Lightning App Builder?

Choose 2 answers

A.Add the page as an available Component type.
B.Assign the page to specific apps.
C.Assign the page as the default record page.
D.Assign the page to user profiles.

Answer: B,C


Question 3:
Which three types of Salesforce IDs can be use to update existing campaign members using the Data Import Wizard?

Choose 3 answers

A.Campaign Member ID
B.User ID
C.Person Account ID
D.Contact ID
E.Lead ID

Answer: A,D,E


Question 4:
What is the most efficient way to change a picklist that uses a global value set from a single-select picklist to a multi-select picklist?

A.Use the Picklist Type Change wizard.
B.Delete the single-select picklist and recreate it as a multi-select picklist.
C.Create a new global value set.
D.Edit the picklist field and use the Change Field Type button.

Answer: D 

Question 5:What custom field type can be used to link one custom metadata type to another custom metadata type by clicking on a lookup icon?

A.Type Link
B.Lookup Relationship
C.Metadata Relationship
D.Master-Detail Relationship

Answer: C


Question 6:
Where can Salesforce Classic, Lightning, and connected apps all be managed in one place in Lightning Experience?

A.Lightning Experience App Manager
B.Lightning Page Tabs
C.Lightning Components
D.Lightning App Builder

Answer: A

Question 7:
Which three steps do users need to complete in order to login without a password using Lightning Login?

Choose 3 answers

A.Verify identity using either a PIN or fingerprint.
B.Navigate to the secret URL provided by an Administrator.
C.From the login screen, click on a Lightning Login-enabled username.
D.Acknowledge the notification sent to the Salesforce Authenticator app.
E.Answer a series of challenge questions.

Answer: A,C,D

Thursday 23 March 2017

Salesforce Certified Platform Developer I - Winter '17 Release Exam

Question 1:
Which Base Lightning Component will display a number of buttons together in the same navigation bar?

A.ui:buttons
B.lightning:buttonGroup
C.lightning:layout
D.ui:navigation

Answer : B

Question 2:
For how many days will the “Quick Deploy” option appear after a Change Set is successfully validated?

A.10
B.15
C.4
D.30

Answer : A

Question 3:
Which new option in Winter ‘17 improves sandbox creation by reducing the data in a Full sandbox? 

A.Data Compression
B.Template Optimizer
C.Login History
D.Content Version History

Answer: D

Question 4:
What are two ways to use the Lightning Design System in Lightning Apps?

Choose 2 answers

A.Copy and paste CSS classes from Lightning Design System to the CSS resource in the Application Bundle
B.Include an attribute with a name of “SLDS” of type “Boolean” that has a default value of true
C.Extend “force:slds” in the < aura:application > tag
D.Reference a Static Resource using “ltng:require”

Answer: C,D

Queston 5:
In Process Builder, how can you make a process reusable and invoke it from other processes or action groups in the same process?

A.Check the Invocable Process checkbox option
B.Reference the process from an Apex method annotated with @InvocableMethod
C.No configuration is required because all processes become invocable in Winter ‘17
D.Select “It’s invoked by another process” from the “The process starts when” picklist

Answer : D

Question 6:

Which two interfaces can be implemented to enable a Lightning Component for Custom Actions?
 Choose 2 answers
A.aura:enableQuickAction
B.lightning:quickActionEnabled
C.force:lightningQuickActionWithoutHeader
D.force:lightningQuickAction

Answer : B,C

Question 7:
Name two required steps for enabling debug logging for unauthenticated Guest Users accessing public Sites.

Choose 2 answers

A.Set the “Assigned Users” in the Site "Public Access Settings” to include the built-in Debug User
B.Install the Sites Page Inspector plugin for Chrome
C.Check the “Enable Guest Access Logging” checkbox option in Site Details
D.Set a browser cookie with a name value of “debug_logs” and a domain value of           “.force.com"
E.Setup a new Trace Flag with a Traced Entity Type of ‘User’ that looks up to the Guest User for a Site

Answer:D,E