A Lightning web component exists in the system and displays information about the record in context as a medal. Salesforce administrators need to use this component within the Lightning App Builder, Which two settings should the developer configure within the xml resource file? Choose 2 answers
Correct Answer: A,B
The two settings that the developer should configure within the xml resource file are to specify the target to be lightning_RecordPage and to set the IsExposed attribute to true. The target element defines where the component can be used, and the lightning_RecordPage value indicates that the component can be used on a Lightning record page. The IsExposed attribute determines whether the component is available in tools such as App Builder or Experience Builder, and setting it to true exposes the component to these tools. The IsVisible attribute is not a valid answer, as it is not a valid attribute for the xml resource file, and it does not affect the availability of the component. The lightning_AppPage value is not a valid answer, as it indicates that the component can be used on a Lightning app page, not a Lightning record page. Reference: [Configure Components for Lightning Pages and the Lightning App Builder], [Lightning Web Components Developer Guide]
PDII Exam Question 22
A developer is asked to develop a new AppFxchange application. A feature of the program creates Survey records when a Case reaches a certain stage and is of a certain Record Type. This feature needs to be configurable, as different Salesforce instances require Surveys at different times. Additionally, the out-of-the-box AppExchange app needs to come with a set of best practice settings that apply to most customers. What should the developer use to store and package the custom configuration settings for the app?
Correct Answer: C
Custom metadata is a type of metadata that allows developers to define custom configuration settings that can be deployed, packaged, and upgraded. Custom metadata can store the logic for creating Survey records based on the Case stage and Record Type, and can be queried and modified using Apex or the Metadata API. Custom metadata can also have default values that apply to most customers, and can be overridden by the customers as needed. Reference: [Custom Metadata Types], [Create, Read, Update, and Delete Custom Metadata Records]
PDII Exam Question 23
Refer to exhibit. Consider the above trigger intended to assign the Account to the manager of the Account's region, Which two changes should a developer make in this trigger to adhere to best practices?
Correct Answer: B,D
The two changes that the developer should make in this trigger to adhere to best practices are to move the Region__c query to outside the loop and to remove the last line updating accountList as it is not needed. Moving the Region__c query to outside the loop avoids the SOQL query limit, as it reduces the number of queries from one per Account record to one for all Account records. The developer can use a Map to store the Region__c records by Name, and then use the Map to assign the OwnerId for each Account record. Removing the last line updating accountList as it is not needed avoids the DML statement limit, as it is redundant to update the records that are already in the trigger context. The developer can use the Trigger.new list to modify the Account records, and the changes will be saved automatically after the trigger execution. Using a Map to cache the results of the Region__c query by Id is not a valid answer, as it does not move the query outside the loop, and it does not match the Name field of the Account record. Using a Map accountMap instead of List accountList is not a valid answer, as it does not affect the query or the DML limits, and it does not change the logic of the trigger. Reference: [Apex Triggers], [Apex Best Practices], [Apex Developer Guide]
PDII Exam Question 24
Business rules require a Contact ta always be created when a new Account is created. What can be used when developing a custom screen to ensure an Account is not created if the creation of the Contact fails?
Correct Answer: A
The best way to ensure that an Account is not created if the creation of the Contact fails is to use setSavepoint() and rollback() with a try-catch block. This way, the developer can mark a point in the transaction before inserting the Account, and then catch any exception that occurs when inserting the Contact. If an exception is caught, the developer can roll back the transaction to the savepoint, which will undo the insertion of the Account. Using the Database.insert method with allOrNone set to false will allow partial success, but it will not prevent the creation of the Account if the Contact fails. Using the Database.delete method if the Contact insertion fails will delete the Account, but it will consume an extra DML statement and might cause other side effects. Disabling validation rules on Contacts and setting default values with a trigger will not ensure the creation of the Contact, and might compromise the data quality and integrity. Reference: [Savepoints and Rollbacks], [Database Class], [Apex Developer Guide]
PDII Exam Question 25
A developer receives complaints that the component loads slowly. Which change can the developer implement to make the component perform faster?
Correct Answer: D
To make the component perform faster, the developer should change the default for showContactInfo to false. The showContactInfo attribute is used to control whether the contactInfo component is rendered or not. By default, it is set to true, which means that the contactInfo component is always rendered, even if the user does not need to see it. This can slow down the component loading, as the contactInfo component may have some complex logic or data fetching in its controller or helper. By changing the default for showContactInfo to false, the developer can improve the component performance, as the contactInfo component will only be rendered when the user clicks on the Show Contact Info button, which triggers the toggleContactInfo function and sets the showContactInfo attribute to true. Changing the type of contactInfo to "Map" would not make the component perform faster, as contactInfo is not a variable, but a component name. A Map is a collection type that stores key-value pairs, and it is not related to the component rendering. Moving the contents of <c:contactInfo> into the component would not make the component perform faster, as it would not change the logic or data fetching of the contactInfo component. It would only make the component code less modular and reusable. Adding a change event handler for showContactInfo would not make the component perform faster, as it would not change the rendering of the contactInfo component. It would only add an extra function that is executed whenever the showContactInfo attribute changes, which may not be necessary for the component functionality. Reference: [Create and Use Attributes], [Render Components Conditionally]