A developer has a Visualforce page and custom controller to save Account records. The developer wants to display any validation rule violation to the user. How can the developer make sure that validation rule violations are displayed?
Correct Answer: B
To display any validation rule violation to the user, the developer needs to include the apex:message component on the Visualforce page. This component displays a custom message or an exception message, depending on the value of the id attribute. If the id attribute matches the id of another component on the page, such as an input field, the apex:message component displays the validation error for that component. If the id attribute is not specified, the apex:message component displays the first exception message generated by the controller. The developer can also use the apex:messages component to display all the messages for the page, not just the first one. Option A is incorrect because adding custom controller attributes to display the message would require additional logic and coding in the controller and the Visualforce page. Option C is incorrect because using a try/catch with a custom exception class would not display the validation rule violation to the user, but rather handle the exception in the controller. Option D is incorrect because performing the DML using the Database.upsert() method would not display the validation rule violation to the user, but rather return a list of Database.SaveResult objects that contain the success or failure status of each record. References: apex:message | Visualforce Developer Guide, ValidationRule | Metadata API Developer Guide, How to Display Validation Rule Errors in Visualforce Page
Question 147
A developer has the controller class below. Which code block will run successfully in an execute anonymous window? myFooController m = new myFooController();
Correct Answer: C
Explanation
Question 148
What should a developer use to implement an automate approval process submission for case?
Correct Answer: D
Question 149
When a user edits the Postal Code on an Account, a custom Account text field named ''Timezone'' must be updated based on the values in a postalCodeToTimezone_c custom object. What should be built to implement this feature?
Correct Answer: A
The best way to implement this feature is to use an Account custom trigger. A trigger is a piece of Apex code that executes before or after a record is inserted, updated, deleted, or undeleted1. In this case, the trigger should execute before an Account record is updated and check if the Postal Code field has changed. If so, the trigger should query the postalCodeToTimezone_c custom object to find the matching Timezone value and assign it to the custom Account text field named Timezone. This way, the Timezone field will be updated automatically based on the Postal Code field. An Account approval process is not suitable for this feature, as it is used to automate the process of approving records based on predefined criteria and actions2. An Account assignment rule is also not suitable, as it is used to assign ownership of Account records to users or queues based on criteria3. An Account workflow rule is not suitable either, as it is used to automate tasks, email alerts, field updates, and outbound messages based on criteria and evaluation rules4. None of these options can update the Timezone field based on the values in a custom object. References: * Apex Developer Guide - Triggers * Salesforce Help - Approval Processes * Salesforce Help - Assignment Rules * Salesforce Help - Workflow Rules
Question 150
A developer is asked to prevent anyone other than a user with Sales Manager profile from changing the Opportunity Status to Closed Lost if the lost reason is blank. Which automation allows the developer to satisfy this requirement in the most efficient manner?
Correct Answer: D
An error condition formula on a validation rule on Opportunity is the automation that allows the developer to satisfy the requirement in the most efficient manner. A validation rule is a declarative feature that allows you to define criteria for data quality and integrity. It can prevent users from saving records that do not meet the specified conditions. In this case, the developer can create a validation rule on the Opportunity object that checks if the user profile is not Sales Manager, the Opportunity Status is Closed Lost, and the lost reason is blank. If these conditions are true, the validation rule can display an error message and prevent the record from being saved12. References: * 1: Validation Rules * 2: Cert Prep: Platform Developer I: Data Modeling and Management