Salesforce interview Question

 Please find below Salewsforce Interview Question which is ask in many interviews.


1)   How to get the RecordType/Id name based on the ID?

Ans: Use following methods to get recordtype Name or Id based on the parameters passed to these methods.

            public static Id getRecordTypeIdbyName(String objectName, String strRecordTypeName)

            {

return  Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfosByName().get(strRecordTypeName).getRecordTypeId();

             }

 

            public static String getRecordTypeNameById(String objectName, Id strRecordTypeId)

            {

 return Schema.getGlobalDescribe().get(objectName).getDescribe().getRecordTypeInfosById().get(strRecordTypeId).getName();

              }  

 

2)   A phased Salesforce rollout is planned. Three deployments will be spread out over 12 months, and the requirements have been carefully documented.
An Architect needs to trace back configuration changes to the requirements.
Which two approaches should the Architect use? (Choose two.)
A. Utilize the Force.com IDE to save the metadata files in source control.
B. Analyze the setup audit trail for configuration changes.
C. Enter the business purpose into the Description of each field.
D. Maintain a data dictionary with the justification for each field.

Ans: c and D

 

3)   A company has a Lightning Page with many Lightning Components, some that cache reference data. It is reported that the page does not always show the most current reference data.
What can a developer use to analyze and diagnose the problem in the Lightning Page?

·       A. Salesforce Lightning Inspector Actions Tab

·       B. Salesforce Lightning Inspector Event Log Tab

·       C. Salesforce Lightning Inspector Transactions Tab

·       D. Salesforce Lightning Inspector Storage Tab

Ans: D

 

 

4)   Considerations for Using the webservice Keyword

Ans: 1) You can't use the web-Service keyword to define an interface,
2) System defined enums cannot be used in Web-service methods
3) You can't use the webService keyword in a trigger
4) All classes that contain methods defined with the webService keyword must be declared as global.
5) Methods defined with the webService keyword are inherently global. These methods can be used by any Apex code that has access to the class. You can consider the webService keyword as a type of access modifier that enables more access than global
6) You should define any method that uses the web-Service keyword as static
7) You can't deprecate webService methods or variables in managed package code
8) Methods defined with the webService keyword cannot take the following elements as parameters. While these elements can be used within the method, they also cannot be marked as return values.

·                 Maps

·                 Sets

·                 Pattern objects

·                 Matcher objects

·                 Exception objects


5) You can use the web-service modifier to define top level, outer class methods and variables, and member variables of an inner class. It can't be used on a class itself, or an interface or interface methods or variables.

NOTE:-  Invoking a custom webService method always uses system context. Consequently, the current user's credentials are not used, and any user who has access to these methods can use their full power, regardless of permissions, field-level security, or sharing rules. Developers who expose methods with the webService keyword should therefore take care that they are not inadvertently exposing any sensitive data

Apex class methods that are exposed through the API with the webService keyword don't enforce object permissions and field-level security by default

global class MyWebService {

    webService static Id makeContact(String lastName, Account a) {

        Contact c = new Contact(lastName = 'Weissman', AccountId = a.Id);

        insert c;

        return c.id;

    }

}

5)   A developer wrote a workflow email alert on case creation so that an email is sent to the case owner manager when a case is created. When will the email be sent?
A . After Committing to database.
B . Before Trigger execution.
C . After Trigger execution.
D . Before Committing to database.

Ans: A

 

6)   How to create component dynamically ?

Ans: $A.createComponent() 

Comments

Popular posts from this blog

Maximizing Your Salesforce Knowledge: Free Certification Offer for Salesforce Certified Associate