Thursday, August 29, 2019

Best Practices to Write Visualforce Pages & Test Classes

Best Practices to Write Visualforce Pages:

Ø  Do not hardcode picklist in Visualforce Page, include them in the Controller instead.

Ø  Javascript & CSS should be included as Static Resources allowing the browser to Cache them.

Ø  Reference CSS at the top and Javascript at the bottom of the Visualforce Page as this provides faster page loads.

Ø  Mark Controller Variable as Transient if they are not needed between server calls. This will make your page load faster as it reduces the size of View State.

Ø  Use <apex:repeat> to iterate over large collections.

Ø  Use the Cache attribute with the <apex:page> component to take advantage of CDN Caching when appropriate.

Best Practices to Write Test Classes:

Ø  Use a consistent Naming convention using Test and the name of the class being tested.

Ø  Should use the @isTest annotation.

Ø  Test method should create all the Test Data needed for the method.

Ø  Use System.assert liberally to prove that the code behaves as expected.

Ø  Write Test Methods for both Pass & Fail for certain conditions and test for Boundary conditions.

Ø  When testing for Governor Limits, use Test.startTest and Test.stopTest and the Limit Class  instead of hardcoding Governor Limits.


Best Practices to write Apex Code & Triggers

Best Practices to write Apex Code:

Ø  Use Aysnchronous Apex(Using @future annotation) when the logic doesn’t need to be executed synchronously.

Ø  Asysnchronous Apex should be bulkified.

Ø  Apex code must provide proper Exception handling.

Ø  Prevent SOQL & SOSL injection attack by using static queries, binding variables and EscapeSingleQuotes method.

Ø  When querying large data, SOQL For loop should be used.

Ø  Use SOSL over SOQL if the requirement matches as it’s much faster.

Ø  Use Apex Limit method to avoid hitting Governor Limit exception.

Ø  No SOQL & SOSL inside for loops.

Ø  No Asynchronous method(@future) inside loops.

Ø  Do not use hardcoded Ids.


Best Practices to write Triggers:

Ø  There should be only One Trigger for each object.

Ø  Avoid complex logic on triggers. To simplify testing and reuse, trigger should delegate to Apex Classes which contain the actual logic.

Ø  Bulkify any helper classes or methods.

Ø  Triggers should be bulkified and be able to process upto 200 records for each call.

Ø  Execute DML statements using Collections instead of individual records per DML statements.

Ø  Use Collections in SOQL Where clause to retrieve all records back in single query.

Ø  Use a consistent Naming Convention using Object Name(e.g.- AccountName).


Sunday, August 18, 2019

Ease Of Access While Developing Lightning Components


Problem Statement:
Whenever we are developing/debugging lightning UI components, we need to refresh our page multiple times in order to see the code changes reflected on the browser or not. This can be time consuming and sometimes confusing too.
Trick:
For development sandboxes, go to Session Setting from setup and disable Enable Secure & Persistent Browser Caching To Improve Performance checkbox. With this, all code changes will be reflected immediately on screen without any delay as we have disabled the cache.
Note:
Please do this only in dev sandboxes only as it may cause performance issues with other LEX components.



Friday, May 31, 2019

Salesforce Interview Sample Questions Part1


1. What is difference between public and global class in Apex ?
  • Public class can be accessed within the same application or namespaces.  
  • Global class can be accessed from any application or namespaces. It is similar like Public access specifier in Java.

2. What is the difference between role hierarchy and sharing rules?will both do the same permissions?
  •  Role hierarchy states that users at higher hierarchy level can get access to it's lower level users.
  • Sharing rule is used to extend the functionality over Role hierarchy.    

3. What is controller extension in Salesforce?
  • A controller extension is an Apex class containing a public constructor and the constructor will take a standard or custom controller object as a single argument

4. What is the difference between Standard Set Controller & Standard List Controller? 
  • Standard Set Controller allows you to create visualforce pages that can display or act on only one record at a time. We can use the same to display a detail page of a record.
  • Standard List Controller allows you to create visualforce pages which can display or act on a set of records. It also contains functions to support pagination. Examples of using the same is to show a list of records, related list records, mass action pages etc.
5.  How to read the parameter value from the URL in Apex?
  • If the name of the parameter is id, then we can get the id value in the following way:

String id = Apexpages.currentPage().getParameters().get('id');

6.  What is the difference between Role & Profile?
  • Role provides record level access to the users and it is not mandatory where Profile defines Object and field level access to the users and every user must have a profile
7.  What is trigger.new and trigger.newMap in Salesforce?
  • Trigger.new is a context variable that contains list of new versions of records which are inserted/updated or going to be inserted or updated.
  • Trigger.newMap is map of Ids to the new versions of the records. It's a key-value pair where key is the Id of the record & value is the SObject record.
8.  Why visualforce pages are served from a different domain?
  • It allows us to improve security standards and helps up tao block cross-site scripting.
9.  What are the differences between SOQL & SOSL?

     SOQL (Salesforce Object Query Language)
  • You can search only one object at a time.
  • Can query all types of fields.
  • Can be used in triggers and classes both.
  • We can perform DML operation on the query result.
     SOSL (Salesforce Object Search Language)  
  • We can search multiple objects at the same time.
  • Can query only email,text and phone number fields only.
  • Can be used only in classes, not in triggers.
  • We can't perform DML operations on search results.
10.  What are the different types of sandboxes in Salesforce?
  • Developer sandbox
  • Developer pro sandbox
  • Partial Copy sandbox
  • Full Copy sandbox

Sunday, May 26, 2019

Prepopulate Field values through URL Hacking in Salesforce

One of the common use cases in Salesforce is to prepopulate some field values while creating records without using Apex or any custom Visualforce page. The values can be static or may be coming from parent record etc. We can easily achieve this by customizing the URL of the new record page and we can launch the customized URL by creating a custom button.

Let’s start by getting a simple understandings that how Salesforce URL works by looking at an example. Navigate to any Account record in your Salesforce instance and go to the Contacts related list. Now click on the New Contact button to create a new contact record. The format of the URL is similar like the following:

https://{yourinstance}.salesforce.com/003/e?retURL=%2F0017F00000HOxcx&accid=0017F00000HOxcx

Let’s briefly discuss about each of the parts of the URL.


003/e
This 3 letters ‘003’ denoting that we are looking  at a particular object record(Contacts for our case), and ‘e’ signifies that we are editing the page to create a new record of the object..
retURL
When you click the ‘Cancel’ button in a new record page, Salesforce redirects to that link mentioned in this parameter.
accid=0017F00000HOxcx
This is the parent record Id(Account Id in this case) passed as a parameter and it is used to prepopulate the Account Name in Contact record.



Let’s start the process step by step:

Step 1: Create a Custom Button:

To Customize the link, we need to create a custom list button that will replace the standard New Contact button in related list of Account. Please check the screen shot to create the same. For now we are using the standard link in URL section.



Step 2: Add the button to the layout:


Let’s add this button to the Contact related list of Account which can be found in Account page layout and remove the Standard New button first, then we need to put the customized link on the newly created button. Navigate to Account page layout, click Related list on the palette section, Go the Contact related list, click on the Edit properties, click on buttons, uncheck standard New button and select the custom New Contact button as follows:




Step 3 : Customize button URL to Prepopulate Fields with simple values:


To prepopulate values, we need to two things, i.e. the Id of the field for which we are prepopulating values and the value itself. For example we are taking First Name of Contact to be auto populated. To get the Id, use Inspect Element of Chrome.



With a static value binding with the Id ‘name_firstcon2', we need to put the Id value combination in the custom button link as a parameter.




And Here is the output: Salesforce auto populates the value of First Name on the Contact record.



Also we can populate values from the parent object by Merge Fields.

Step 4 : Prepopulate custom look up fields:

There are 2 parameters that we need to auto populate custom look up fields. The first part is used to populate the name of the record we are populating. To do the same, we need the Id of the field as previous, but this time we need the prefix “CF” to be added with the Id. This is required when we are working with a custom look up field. 
After adding the parameter we can expect the button parameter should look like this:

/003/e?CF00N7F00000RoX7i= {!Opportunity.Name}

The next step is to grab the Id of the Opportunity record we wish to populate. This time we have to add a parameter on the URL with the look up field ID suffixed with “_lkId”. The suffix “_lkId”  is denoting that this is a look up field. 
So after adding the same, the URL should look like the following:

/003/e?CF00N7F00000RoX7i= {!Opportunity.Name}&CF00N7F00000RoX7i_lkId= {!Opportunity.Id}





Friday, May 3, 2019

Salesforce Certification PD1 Sample Questions 2019 Part 2


1. How can a developer set up a debug log on a specific user?

  Ask the user for access to their account credentials, log in as the user and debug the issue
  Create Apex code that logs code actions into a custom object
  It is not possible to setup debug logs for users other than yourself
  Set up a trace flag for the user, and define a logging level and time period for the race

2. A developer needs to create a baseline set of data (Accounts, Contacts, Products, Assets) for an entire suite of tests allowing them to test independent requirements various types of Salesforce Cases. Which approach can efficiently generate the required data for each unit test?

  Use @TestSetup with a void method
  Create a mock using the Stub API
  Create test data before Test.startTest() in the unit test
  Add @IsTest (see AllData=true) at the start of the unit test class

3. Requirements state that a child record be deleted when its parent is deleted, and a child can be moved to a different parent when necessary. Which type of relationship should be built between the parent and child objects in Schema builder to support these requirements?

  Lookup relationship from the child to the parent
  Child relationship
  Master-Detail relationship
  Lookup relationship from the parent to the child

4. Which two ways can a developer instantiate a PageReference in Apex?

  By using ApexPages.currentpage()
  By using an object standard set controller action
  By using an object standard controller action
  By using the PageReference.getURL() method

5. A Visualforce page uses the Contact standard controller. How can a developer display the Name from the parent Account record on the page?

  Use SOQL syntax to find the related Accounts Name field
  Use an additional standard controller for Accounts
  Use the {!contact.Account.Name} merge field syntax
  Use additional Apex logic within the controller to query for the Name field

6. A developer is creating a Visualforce page that allows users to create multiple Opportunities. The developer is asked to verify the current user's default Opportunity record type, and set certain default values based on the record type before inserting the record. How can the developer find the current user's default record type?

  Create the opportunity and check the opportunity.recordType before inserting, which will have the record ID of the current user's default record type
  Use Opportunity.sObjectType.getDescribe().getRecordTypeInfos() to get a list of record types, and iterate through them until isDefaultRecordTypeMapping is true
  Use the Schema.userInfo.Opportunity.getDefaultRecordType() method
  Query the Profile where the ID equals userInfo.getProfileID() and then use the profile.Opportunity.getDefaultRecordType() method

7. What is considered the primary purpose for creating Apex tests?

  To guarantee at least 50% of code is covered by unit tests before it is deployed
  To ensure every use case of the application is covered by a test
  To confirm every trigger is executed at least once
  To confirm all classes and triggers compile successfully

8. The sales team at Universal Containers would like to see a visual indicator appear on both Account and Opportunity page layouts to alert salespeople when an Account is late making payments or has entered the collections process. What can a developer implement to achieve this requirement without having to write custom code?

  Workflow Rule
  Quick Action
  Formula Field
  Roll-up Summary Field

9. Which two statements are true about Apex code executed in Anonymous Blocks?

  Successful DML operations are automatically committed
  The code runs with the permissions of the logged in user
  The code runs in system mode having access to all objects and fields
  The code runs with the permissions of the user specified in the runAs() statement

10. Which tag should a developer include when styling from external CSS is required in a Visualforce page?

  apex:includeScript
  apex:includeStyles
  apex:stylesheet
  apex:require

11. Given the code block:

      Integer x;
      for(x = 0; x<10; x+=2){
         if(x==8)
         break;
         if(x==10)
         break;
      }
      System.debug(x);

Which value will the system.debug statement display?

  8
  2
  10
  12

12. Which two roll-up summary field types are required to find the average of values on detail records in a Master-Detail relationship?

  Roll-up summary field of type SUM
  Roll-up summary field of type COUNT
  Roll-up summary field of type TOTAL
  Roll-up summary field of type NUM

13. How can a developer warn users of SOQL governor limit violations in a trigger?

  Use PageReference.setRedirect() to redirect the user to a custom Visualforce page before the number of SOQL queries exceeds the limit
  Use Limits.getQueries and display an error message before the number of SOQL queries exceeds the limit
  Use ApexMessage.Message() to display an error message after the number of SOQL queries exceeds the limit
  Use Messaging.SendEmail to continue the transaction and send an alert to the user after the number of SOQL

14. What is a benefit of using a trigger framework?

  Reduces trigger execution time
  Allows functional code to be tested by a test class
  Simplifies addition of context-specific logic
  Increases trigger governor limits

15. When a Task is created for a Contact, how can a developer prevent the task from being included on the Activity Timeline of the Contacts Account record?

  Create a Task trigger to set the Account field to NULL
  In Activity Settings, uncheck Roll up activities to a contact's primary account
  Use Process Builder to create a process to set the Task Account field to blank
  By default, tasks do not display on the Account Activity Timeline

16. A developer wants to use all of the functionality provided by the standard controller for an object, but needs to override the Save standard action in a controller extension. Which two are required in the controller extension class?

  Define the class with a constructor that takes an instance of Standard Controller as a parameter
  Create a method named Save with a return data type of PageReference
  Create a method that references this.supersave()
  Define the class with a constructor that creates a new instance of the Standard Controller class

17. An Apex transaction inserts 100 Account records and 2,000 Contact records before encountering a DML exception when attempting to insert 500 Opportunity records. The Account records are inserted by calling the database.insert() method with the allorNone argument set to false. The Contact and Opportunity records are inserted using the standalone insert statement. How many total records will be committed to the database in this transaction?

  100
  0
  2100
  2000

18. What is a key difference between a Master-Detail Relationship and a Lookup Relationship?

  A Master-Detail Relationship detail record inherits the sharing and security of its master record
  When a record of a master object in a Lookup Relationship is deleted, the detail records are also deleted
  A Lookup Relationship is a required field on an object
  When a record of a master object in a Master-Detail Relationship is deleted, the detail records are kept and not deleted

19. A developer working on a time management application wants to make total hours for each timecard available to application users. A timecard entry has a Master-Detail relationship to a timecard. Which approach should the developer use to accomplish this declaratively?

  A Roll-Up Summary field on the Timecard Object that calculates the total hours from timecard entries for that timecard
  A Visualforce page that calculates the total number of hours for a timecard and displays it on the page
  An Apex trigger that uses an Aggregate Query to calculate the hours for a given timecard and stores it in a custom field
  A Process Builder process that updates a field on the timecard when a timecard entry is created

20. Which type of code represents the Model in the MVC architecture on the Force.com platform?

  A Controller Extension method that saves a list of Account records
  Custom JavaScript that processes a list of Account records
  A Controller Extension method that uses SOQL to query for a list of Account records
  A list of Account records returned from a Controller Extension method

21. For which example task should a developer use a trigger rather than a workflow rule?

  To set the Name field of an expense report record to Expense and the Date when it is saved
  To notify an external system that a record has been modified
  To set the primary Contact on an Account record when it is saved
  To send an email to a hiring manager when a candidate accepts a job offer

22. A developer wants to display all of the picklist entries for the Opportunity StageName field and all of the available record types for the Opportunity object on a Visualforce page. Which two actions should the developer perform to get the available picklist values and record types in the controlller? Choose 2 answers

  Use Schema.RecordTypeInfo returned by RecordType.sObjectType.getDescribe().getRecordTypeInfos()
  Use Schema.PicklistEntry returned by Opportunity.sObjectType.getDescribe().getPicklistValues()
  Use Schema.PicklistEntry returned by Opportunity.StageName.getDescribe().getPicklistValues()
  Use Schema.RecordTypeInfo returned by Opportunity.sObjectType.getDescribe().getRecordTypeInfos()

23. A company wants to create an employee rating program that allows employees to rate each other. An employee's average rating must be displayed on the employee record. Employees must be able to create rating records, but are not allowed to create employee records. Which two actions should a developer take to accomplish this task? Choose 2 answers.

  Create a master-detail relationship between the Rating and Employee objects
  Create a trigger on the Rating object that updates a field on the Employee object
  Create a lookup relationship between the Rating and Employee object
  Create a roll-up summary field on the Employee and use AVG to calculate the average rating score

24. which two SOSL searches will return records matching search criteria contained in any of the searchable text fields on an object? Choose 2 answers

  [FIND 'Acme*' IN ALL FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' IN TEXT FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' IN ANY FIELDS RETURNING Account, Opportunity];
  [FIND 'Acme*' RETURNING Account, Opportunity];

25. A developer needs to include a Visualforce page in the detail section of a page layout for the Account object, but does not see the page as an available option in the Page Layout Editor. Which attribute must the developer include in the tag to ensure the Visualforce page can be embedded in a page layout?

  action="AccountId"
  controller="Account"
  standardController="Account"
  extensions="AccountController"

26. Which two statements are true regarding formula fields? Choose 2 answers

  When concatenating fields, line breaks can be added to improve readability
  Fields that are referenced by a formula field can not be deleted until the formula is modified or deleted
  Formula fields may reference formula fields on the same object to a level of one deep
  When using the & operator to concatenate strings, the result is automatically truncated to fit the destination

27. The Account object has a custom formula field, Level_c, that is defined as a Formula (Number) with two decimal places. Which three are valid assignments? Choose 3 answers

  Long myLevel = acct.Level__c;
  Decimal myLevel = acct.Level__c;
  Integer myLevel = acct.Level__c;
  Object myLevel = acct.Level__c
  Double myLevel = acct.Level__c

28. A developer declared a class as follows.

      public class wysiwyg {

// properties and methods including DML

}
Which invocation of a class method will obey the organization-wide defaults and sharing settings for the running user in the Salesforce organization?

  An Apex trigger that invokes a helper method in this class
  A user on an external system that has an API call into Salesforce that invokes a method in this class
  A Visualforce page with an Apex controller that invokes a method in this class
  A developer using the Developer Console that invokes a method in this class from the execute anonymous window

29. A developer uses a Test Setup method to create an Account named 'Test'. The first test method deletes the Account record. What must be done in the second test method to use the Account?

  Call the Test Setup method at the start of the test
  The Account cannot be used in the second test method
  Use SELECT Id from Account where Name = 'Test'
  Restore the Account using an undelete statement

30. A developer needs to create a custom Visualforce button for the Opportunity object page layout that will cause a web service to be called and redirect the user to a new page when clicked. Which three attributes need to be defined in the tag of the Visualforce page to enable this functionality? Choose 3 answers

  standardController
  readOnly
  renderAs
  extensions
  action

31. A developer has the following class and trigger code.

      public class InsuranceRates {
public static final Decimal smokerCharge = 0.01;
}

trigger ContactTrigger on Contract(before insert){
InsuranceRates rates = new InsuranceRates();
Decimal baseCost=XXX;

}

Which code segment should a developer insert at the XXX to set the baseCost variable to the value of the class variable smokerCharge?

  InsuranceRates.smokerCharge
  rates.getSmokerCharge()
  ContactTrigger.InsuranceRates.smokerCharge
  rates.smokerCharge

32. Which statement is true about developing in a multi-tenant environment?

  Governor limits prevent Apex from impacting the performance of multiple tenants on the same instance
  Apex Sharing controls access to records from multiple tenants on the same instance
  Org-level data security controls which users can see data from multiple tenants on the same instance
  Global Apex classes can be referenced from multiple tenants on the same instance

33. Opportunity opp = (SELECT id, StageName FROM Opportunity LIMIT 1];
Given the code above, how can a developer get the label for the StageName field?

  Call "Opportunity.StageName.Label"
  Call "Opportunity.StageName.getDescribe().getLabel()"
  Call "opp.StageName.getDescribe().getLabel()"
  Call "opp.StageName.Label"


Saturday, April 27, 2019

Salesforce Certification PD1 Sample Questions 2019 Part1


1. A developer needs to create a baseline set of data (Accounts, Contacts, Products, Assets) for an entire suite of tests allowing them to test independent requirements various types of Salesforce Cases. Which approach can efficiently generate the required data for each unit test?

  Use @TestSetup with a void method.
   Create a mock using the Stub API.
   Create test data before Test.startTest() in the unit test.
   Add @IsTest (see AllData=true) at the start of the unit test class.

2. Which three resources in a Lightning Component Bundle can contain JavaScript functions?

   Helper
   Renderer
   Controller
   Design
   Style

3. which query should a developer use to obtain the Id and Name of all the Leads, Accounts, and Contacts that have the company name "Universal Containers"?

  FIND 'Universal Containers' IN Name Fields RETURNING lead(id, name), account(id, name), contact(id, name)
   SELECT Lead.id, Lead.Name, Account.Id, Account.Name, Contact.id, Contact.Name FROM Lead, Account,Contact WHERE Company Name = 'Universal Containers'
   SELECT lead(id, name), account(id, name), contact(id, name) FROM Lead, Account, Contact WHERE Name ='Universal Containers'
   FIND 'Universal Containers' IN CompanyName Fields RETURNING lead(id, name), account(id, name), contact(id,name)

4. A developer needs an Apex method that can process Account or Contact records. Which method signature should the developer use?

   public void doWork(Account || Contact)
   public void doWork(Record theRecord)
   public void doWork(sObject theRecord)
   public void doWork(Account Contact)

5. Which two combined methods should a developer use to prevent more than one open Opportunity on each Account? Choose 2 answers

   Create an Account Roll-up Summary field to count open Opportunities
   Create an opportunity Workflow Rule to auto-close the opportunity
   Create an Account Trigger to generate an error on Opportunity insert
   Create an opportunity Validation Rule to generate an error on insert.

6. Which two conditions cause workflow rules to fire?

   Changing the territory assignments of accounts and opportunities
   Updating records using the bulk API
   Converting leads to person accounts
   An Apex Batch process that changes field values

7. A developer needs to create an audit trail for records that are sent to the recycle bin. Which type of trigger is most appropriate to create?

   after undelete
   before delete
   after delete
   before undelete

8. From which two locations can a developer determine the overall code coverage for a sandbox?

   The Test Suite Run panel of the Developer Console
   The Tests tab of the Developer Console
   The Apex Test Execution page
   The Apex classes setup page

9. Which two approaches optimize test maintenance and support future declarative configuration changes? Choose 2

   Create a method that loads valid Account records from a static resource, then call this method within test methods
   Create a method that creates valid records, then call this method within test methods
   Create a method that queries for valid records, then call this method within test methods
   Create a method that performs a callout for valid records, then call this method within test methods

10. A developer is creating an enhancement to an application that will allow people to be related to their employer. Which data model should be used to track the data?

   Create a junction object to relate many people to many employers through master-detail relationships
   Create a junction object to relate many people to many employers through lookup relationships
   Create a lookup relationship to indicate that a person has an employer
   Create a master-detail relationship to indicate that a person has an employer

11. A developer uses an after update trigger on the Account object to update all the Contacts related to the Account. The trigger code shown below is randomly failing.


 List<Contact> theContacts = new List<Contact>(); 

 for (Account a : Trigger.new) { 
   for (Contact c : (SELECT Id, Account_Date__C FROM Contact WHERE AccountId = :a.Id]) { 
     c.Account_Date__c = Date.today(); 
     theContacts.add(c);
   } 
 } 
update theContacts;

Which line of code is causing the code block to fail?

   A SOQL query is located inside of the for loop
   The trigger processes more than 200 records in the for loop
   An exception is thrown if Account_Date_c is null
   An exception is thrown if theContacts is empty

12. Managed Packages can be created in which type of org?

   Developer Sandbox
   Developer Edition
   Partial Copy Sandbox
   Unlimited Edition

13. A developer needs to find information about @future methods that were invoked. From which system monitoring feature can the developer see this information?

   Background Jobs
   Asynchronous Jobs
   Scheduled Jobs
   Apex Jobs

14. How can a developer use a Set to limit the number of records returned by a SOQL query?

   Pass the Set as an argument in a reference to the Database.query() method
   Reference the Set in the WHERE clause of the query
   Pass the query results as an argument in a reference to the Set.containsAll() method
   Reference the set in the LIMIT clause of the query

15. In the code below, which type does String inherit from?
String s = 'Hello World';


   Prototype
   Class
   sObject
   Object

16. Which two queries can a developer use in a Visualforce controller to protect against SOQL injection vulnerabilities?

    String qryName = '%' + String.escapeSingleQuotes(name) + '%';
String qryString = 'SELECT ID FROM
WHERE Name LIKE \'%'+qryName+'%\'';
List<Contact> queryResult = Database.query(qryString);

    String qryName = '%' + name + '%';
String gryString = 'SELECT Id FROM Contact WHERE Name LIKE :qryName';
List<Contact> queryResult = Database.query(qryString);

    String gryString = 'SELECT Id FROM Contact WHERE Name
LIKE \'%' + name + '\'%';
List<Contact> queryResult = Database.query(qryString);

    String qryName = '%' + String.enforceSecurityChecks(name) + '%';
String gryString = 'SELECT Id FROM Contact WHERE Name :qryName;
List<Contact> queryResult = Database.query(qryString);

17. Which declarative process automation feature supports iterating over multiple records?

   Flows
   Validation rules
   Approval processes
   Workflow

18. Which is a valid Apex assignment?

   Integer x = 5.0;
   Integer x = 5 * 1.0;
   Float x = 5.0;
   Double x = 35

19. A developer creates a custom controller and custom Visualforce page by using the code block below.

   b, a, getMyString
   a, b, getMyString
   a, a, a
   a, b, b

20. A developer wants to store a description of a product that can be entered on separate lines by a user during product setup and later displayed on a Visualforce page for shoppers.Which field type should the developer choose to ensure that the description will be searchable in the custom Apex SOQL queries that are written?

   Text
   Text Area
   Text Area (Rich)
   Text Area (Long)

21. What are two benefits of the Lightning Component framework? Choose 2 answers

   It simplifies complexity when building pages, but not applications
   It provides an event-driven architecture for better decoupling between components
   It allows faster PDF generation with Lightning components
   It promotes faster development using out-of-the-box components that are suitable for desktop and mobile devices.

22. Which option should a developer use to create 500 Accounts and make sure that duplicates are not created for existing Account Sites?

   Data Import Wizard
   Sandbox Template
   Salesforce-to-Salesforce
   Data Loader

23. An Account trigger updates all related Contacts and Cases each time an Account is saved using the following two DML statements:

update allconacts;
update allCases;

What is the result if the Case update exceeds the governor limit for maximum number of DML records?
   The Account save succeeds and no Contacts or Cases are updated
   The Account save is retried using a smaller trigger batch size
   The Account save succeeds, Contacts are updated, but Cases are not
   Account save fails and no Contacts or Cases are updated

24. A Platform Developer needs to write an Apex method that will only perform an action if a record is assigned to a specific Record Type. Which two options allow the developer to dynamically determine the ID of the required Record Type by its name? Choose 2 answers

   Execute a SOQL query on the RecordType object
   Hardcode the ID as a constant in an Apex class
   Make an outbound web services call to the SOAP API
   Use the getRecordTypeInfosByName() method in the DescribesObjectResult class

25. How many levels of child records can be returned in a single SOQL query from one parent object?

   1
   3
   5
   7

26. A developer created a Visualforce page and a custom controller with methods to handle different buttons and events that can occur on the page.What should the developer do to deploy to production?

   Create a test class that provides coverage of the Visualforce page
   Create a test class that provides coverage of the custom controller
   Create a test page that provides coverage of the Visualforce page
   Create a test page that provides coverage of the custom controller

27. Which two statements can a developer use to throw a custom exception of type MissingFieldValueException?

   throw new MissingFieldValueException('Problem occurred');
   throw (MissingFieldValueException, 'Problem occurred');
   throw Exception(new MissingFieldValueException());
   throw new MissingFieldValueException();

28. A change set deployment from a sandbox to production fails due to a failure in a managed package unit test. The developer spoke with the managed package owner and they determined it is a false positive and can be ignored. What should the developer do to successfully deploy?

   Edit the managed package's unit test
   Select "Fast Deploy" to run only the tests that are in the change set
   Select "Run local tests" to run only the tests that are in the change set
   Select "Run local tests" to run all tests in the org that are not in the managed package

29. Which two components are available to deploy using the Metadata API?

   Web-to-Lead
   Lead Conversion Settings
   Web-to-Case
   Case Settings

30. A developer wants to handle the click event for a lightning:button component. The onclick attribute for the component references a JavaScript function in which resource in the component bundle?

   helper.js
   renderer.js
   handler.js
   controller.js

31. A developer needs to provide a way to mass edit, update, and delete records from a list view. In which two ways can this be accomplished? Choose 2 answers

   Configure the user interface and enable both inline editing and enhanced lists
   Create a new Visualforce page and Apex Controller for the list view that provides mass edit, update, and delete functionality
   Download an unmanaged package from the AppExchange that provides customizable mass edit, update, and delete functionality
   Download a managed package from the AppExchange that provides customizable Enhanced List Views and buttons

32. Which two statements are acceptable for a developer to use inside procedural loops? 

   Account a = (SELECT ID, Name FROM Account WHERE Id = icon.AccountId LIMIT 1];
   delete contactList;
   contactList.remove(i);
   Contact con = new Contact();