Top 25 Interview Salesforce Q&A High Level - 1


Top 25  Interview Q&A High Level - 1

1.Whenever case is created send email to case owner. How to do that?

Answer : 

We can do it using workflow.

2.How to call Future methods from Process Builder?

Answer : 

To call Future methods from Process Builder, call the future method from the invocable method.

3.What is System.RunAs?

 Answer : 

Generally, all Apex code runs in system mode, where the permissions and record sharing of the current user are not taken into account. 
  • The system method runAs enables us to write test methods that change the user context to an existing user or a new user so that the user’s record sharing is enforced.
  • The runAs method doesn’t enforce user permissions or field-level permissions, only record sharing.
  • We can use runAs only in test methods
4.What are Mixed DML Exception?

 Answer :

This error means that two sObjects (setup & non-setup) that we are using in our code can not mix during the same transactions. This restriction exists because some sObjects affect the user’s access to records in the org.
For example
  • We cannot insert an account and then insert a user or a group member in a single transaction.
  • To avoid this error, we should perform DML operation on standard/custom object records in a different transaction.
5.What are the solutions for Mixed DML Operation?

 Answer :

Solution For Mixed DML Operation.
  • Separate the Setup object and Non-Setup object dml operation using Future Method.
  • System.RunAs : Enclose mixed DML operations within System. runAs blocks to avoid the mixed DML error in test class.
6.Difference between before and after trigger?

Answer :

Before triggers can be used to update or validate record values before they are saved to the database.
Use Before Trigger :In the case of validation check in the same object. Insert or update the same object.

After triggers can be used to access field values that are set by the database (such as a record’s Id or last Updated field) and to affect changes in other records, such as logging into an audit table or firing asynchronous events with a queue. Use After Trigger :Insert/Update related object, not the same object.
Notification email.

Note:
  • We cannot use After trigger if we want to update a record because it causes read only error. This is because, after inserting or updating, we cannot update a record.

7.What are the best practice in avoiding Trigger Recursion?

Answer :
  • One Trigger Per Object
  • Logic-less Triggers – use Helper classes to handle logic.
  • Code coverage 100%
  • Handle recursion – To avoid the recursion on trigger, we should make sure our trigger is getting executed only one time.
8.What are scenarios where we can use without sharing?

Answer :

Without Sharing
  • If we have VF page in which we are showing “Sales Rep Performance” which displays a flag in red, green and yellow. Now ideally this field should not be visible whenever a Sales Rep accesses this page. But it is always visible if the class has no keyword specified or if a class has without sharing specified.
  • We want to use apex class globally for integration purpose ,then we can use without sharing.
9.Is apex class always execute in system context?

Answer :

Yes, apex class always execute in system context 
i.e. Apex code has access to all objects and fields irrespective of the logged in User.

10.What are the considerations while using with sharing?

Answer :
  • If the class is not declared as With Sharing or Without Sharing then the class is by default taken as Without Sharing.
  • Both inner classes and outer classes can be declared as With Sharing.
  • If inner class is declared as With Sharing and top level class is declared as Without Sharing, then by default entire context will run in With Sharing Context.
  • If a class is not declared as With/Without Sharing and if this class is called by another class in which sharing rules is enforced then both the classes run with With Sharing.
  • Outer class is declared as With Sharing and inner class is declared as Without Sharing, then inner class runs in Without Sharing Context only(Inner class don’t take the Sharing properties from outer class).
            



11.What is the difference between apex managed sharing and with sharing?

Answer :

Apex Managed Sharing is used to grant the access to the records. It is about pro grammatically configuring sharing rules. Keyword “With Sharing” is used to respect the current user sharing rule.

12.What are considerations while using apex managed sharing?

Answer :
  • If record owner changes, then sharing created through apex managed sharing are maintained but if user share record manually, then record sharing will be lost if owner changes.
  • User with “modify All Data” can only add, edit or delete records in share table.
13.What are the limitations of manual sharing?

Answer :
  • Manual Sharing cannot be stricter than Organization Wide Defaults.
  • Manual Sharing is only available on individual records, it is not available for all records of a certain object.
  • Only applicable on records that have Private or Public Read Only access in OWD.
  • When setting Automatic and Manual Sharing users and admins should define if the security should be extended to related records.
14.What is database savepoint?

Answer :
    database savepoint is a method which is used to define a point which can be roll back to. If any error occurs during a transaction, that contains many statements, the application will roll back to the most recent savepoint and the entire transaction will not be aborted.

    15.What are the considerations while using save point?

    Answer :
      • If you set more than one savepoint, then roll back to a savepoint that is not the last savepoint you generated, the later savepoint variables become invalid.
      • References to savepoints cannot cross trigger invocations, because each trigger invocation is a new execution context. If you declare a savepoint as a static variable then try to use it across trigger contexts you will receive a runtime error.
      • Each savepoint you set counts against the governor limit for DML statements.
      16.What is database.rollback?

      Answer :
        Rollback is an operation which returns the database to some previous state. Rollbacks are important for database integrity, because they mean that the database can be restored to a clean copy even after erroneous operations are performed.

        17.How to deactivate a validation for a particular user in production?

        Answer :
          For deactivating for a particular user we will use hierarchy Custom Settings: A type of custom setting that uses a built-in hierarchical logic that lets us personalize settings for specific profiles or users.

          18.What is external ID?

          Answer :
            An external ID is a custom field that has the “External ID” attribute, meaning that it contains unique record identifiers from a system outside of Salesforce.

            19.What is the use of external Id?

            Answer :
              • It is mainly use for integration purpose.
              • The field becomes searchable in the sidebar search.
              • We can use the upset API call with the external ID to refer to records.
              20.What is Unique ID?

              Answer :
                Every Record, regardless of entity type, has a globally unique identification value in its ID field which is generated at the time of record creation. That Record ID value will never change, even if the record is deleted and then undeleted.

                21.Why and How to Convert a 15-character Id to an 18-character Id?

                Answer :
                  We can convert 15 character IDs to 18 character IDs to update records, or to make it easier to work in systems that aren’t case sensitive. Create a formula that will give you the 18-character Id of records.
                   
                  22.What is custom login flows? 

                  Answer :
                   
                  Login flow is powerful solution for organization. Flow designer is a point-and-click tool that lets you automate business processes by building flows.

                  Common uses cases includes
                  • Collecting and updating user data at login
                  • Configuring two-factor authentication
                  • Integrating third-party strong authentication methods.
                  23.What is TOTP?

                  Answer :
                    TOTP is time-based one-time password. We can use login flow that enhances TOTP authentication with a two-factor authentication method that Salesforce supports. The TOTP algorithm computes a one-time password from a shared secret key and the current time.
                     
                    Users can use a time-based authentication application (such as Salesforce Authenticator or Google Authenticator) to scan the QR code and generate a TOTP token.

                    24.What is InvocableMethod Annotation?

                    Answer :

                    This annotation lets us mark an Apex method as being something that can be called from somewhere other than Apex.

                    25.Can we call apex class from process builder?

                    Answer :

                    Yes we can call an apex class from process builder. 
                    To call an Apex method, add the Call Apex action to your process and select an Apex class with a @invocable method Annotation.


                    Support us


                    Thank you,
                    SFDC Telugu.








                    Watch Salesforce Telugu Videos
                    Subscribe : SFDC Telugu


                    Post a Comment

                    0 Comments