Free Salesforce CRT-450 Exam Actual Questions

The questions for CRT-450 were last updated On Dec 16, 2024

Question No. 1

Universal Containers wants Opportunities to no longer be editable when it reaches the Closed/Won stage.

Which two strategies can a developer use to accomplish this?

Show Answer Hide Answer
Correct Answer: A, B

Universal Containers wants to prevent Opportunities from being edited once they reach the Closed/Won stage. To achieve this, the developer can use the following strategies:

Option A: Use a validation rule.

Correct Approach.

A validation rule can be created on the Opportunity object to prevent users from editing records when the Stage is Closed/Won.

The validation rule would evaluate whether the record's StageName is 'Closed Won' and, if so, display an error message when a user attempts to edit and save the record.

Example Validation Rule:

AND(

ISPICKVAL(StageName, 'Closed Won'),

ISCHANGED(ANYFIELD) // Replace ANYFIELD with specific fields if needed

)

Benefits:

Declarative Solution: No code required.

Consistent Enforcement: Applies across all user interfaces and API.

An Apex trigger can be written to check if an Opportunity record being modified has a StageName of 'Closed Won'.

In a before update trigger, the trigger can prevent the save operation by adding an error to the record.

Sample Apex Trigger:

trigger PreventOpportunityEdit on Opportunity (before update) {

for (Opportunity opp : Trigger.new) {

Opportunity oldOpp = Trigger.oldMap.get(opp.Id);

if (oldOpp.StageName == 'Closed Won' && opp != oldOpp) {

opp.addError('Closed Won Opportunities cannot be edited.');

}

}

}

Benefits:

Programmatic Control: Allows for complex logic.

Granular Enforcement: Can specify exact conditions under which edits are prevented.

Approval Processes are designed for record approval workflows.

They do not inherently prevent edits based on a field value like StageName.

Option D: Use an auto-response rule.

Incorrect.

Auto-response rules are used to send automated email responses to Leads or Cases.

They do not control record editability.

Conclusion:

The most appropriate strategies are A (Validation Rule) and B (Before-save Apex Trigger).

Both methods effectively prevent users from editing Opportunities in the Closed/Won stage.


Validation Rules

Validation Rule Examples

Option B: Use a before-save Apex trigger.

Correct Approach.

Apex Triggers

Trigger Context Variables

Options Not Suitable:

Option C: Use an automatically launched Approval Process.

Incorrect.

Question No. 2

A developer is creating a 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?

Show Answer Hide Answer
Correct Answer: A

To find the current user's default record type for Opportunity, the developer can use the DescribeSObjectResult and RecordTypeInfo classes.

Option A: Use Opportunity.SObjectType.getDescribe().getRecordTypeInfos() to get a list of record types, and iterate through them until isDefaultRecordTypeMapping() is true.

Correct Approach.

// Get describe result for Opportunity

Schema.DescribeSObjectResult oppDescribe = Opportunity.SObjectType.getDescribe();

// Get list of RecordTypeInfo

List<Schema.RecordTypeInfo> recordTypeInfos = oppDescribe.getRecordTypeInfos();

// Iterate through RecordTypeInfo to find the default one

Id defaultRecordTypeId;

for (Schema.RecordTypeInfo rtInfo : recordTypeInfos) {

if (rtInfo.isAvailable() && rtInfo.isDefaultRecordTypeMapping()) {

defaultRecordTypeId = rtInfo.getRecordTypeId();

break;

}

}


Options Not Applicable:

Option B and C: Methods mentioned do not exist in the API.

Option D: Create the Opportunity and check the Opportunity.RecordTypeId before inserting.

The RecordTypeId is not automatically populated before inserting.

Conclusion:

To find the current user's default Opportunity record type, the developer should use Option A.

Question No. 3

When using Salesforce DX, what does a developer need to enable to create and manage scratch orgs?

Show Answer Hide Answer
Correct Answer: A

When using Salesforce DX, developers need to enable the Dev Hub in their org to create and manage scratch orgs.

Option A: Dev Hub

Correct Answer.

The Dev Hub is a feature that must be enabled in a Salesforce org (usually in a Developer Edition or a production org).

It allows developers to create and manage scratch orgs using Salesforce DX commands.

Dev Hub is the central point for creating and managing your scratch orgs.

While Dev Hub can be enabled in a production org, simply having a production org is not sufficient. Dev Hub must be explicitly enabled.

Option C: Environment Hub

Incorrect.

The Environment Hub is used to manage multiple orgs but is not required for Salesforce DX scratch orgs.

Option D: Sandbox

Incorrect.

Scratch orgs are not created from sandboxes, and enabling scratch org creation requires Dev Hub.

Conclusion:

To create and manage scratch orgs with Salesforce DX, the developer needs to enable Dev Hub.


Enable Dev Hub in Your Org

Salesforce DX Developer Guide

Incorrect Options:

Option B: Production

Incorrect.

Question No. 4

Universal Containers (UC) uses out-of-the-box order management, that has a Master-Detail relationship between Order and Order Line Item.

UC stores the availability date on each Order Line Item and Orders are only shipped when all of the Order Line Items are available.

Which method should be used to calculate the estimated ship date for an Order?

Show Answer Hide Answer
Correct Answer: A

Universal Containers (UC) wants to calculate the estimated ship date for an Order, which should be the date when all Order Line Items are available. The availability date is stored on each Order Line Item.

Given that the relationship between Order and Order Line Item is Master-Detail, we can leverage Roll-Up Summary Fields to perform calculations on the child records (Order Line Items) and summarize them on the parent record (Order).

Option A: Use a MAX Roll-Up Summary field on the latest availability date fields.

Correct Approach.

Create a Roll-Up Summary Field on the Order object.

Use the MAX function to calculate the latest availability date among all related Order Line Items.

The Roll-Up Summary Field will display the maximum (latest) availability date, which represents the date when all items are available.

This date can be used as the estimated ship date for the Order since the Order can only be shipped when all items are available.

Benefits:

Declarative Solution: No code required.

Real-Time Calculation: Automatically updates when Order Line Items change.

The CEILING function returns the smallest integer greater than or equal to a number.

It is used with numerical values, not date fields.

Does not help in calculating the latest date among multiple dates.

Option C: Use a LATEST formula on each of the latest availability date fields.

Non-Existent Function.

There is no LATEST function available in Salesforce formula fields.

Cannot be used to calculate dates.

Option D: Use a DAYS formula on each of the availability date fields and a COUNT Roll-Up Summary field on the Order.

Does Not Address the Requirement.

The DAYS function returns the number of days between two dates.

Using COUNT Roll-Up Summary counts the number of child records but does not help in finding the latest date.

This approach does not calculate the estimated ship date based on the latest availability date.

Conclusion:

Using a MAX Roll-Up Summary Field on the Order object to find the latest availability date among Order Line Items is the appropriate method.

This method efficiently calculates the estimated ship date for an Order based on when all items are available.


Roll-Up Summary Fields

Defining Roll-Up Summary Fields

Why Other Options are Not Suitable:

Option B: Use a CEILING formula on each of the latest availability date fields.

Incorrect Function Usage.

Question No. 5

A developer is creating an app that contains multiple Lightning web components.

One of the child components is used for navigation purposes. When a user clicks a button called Next in the child component, the parent component must be alerted so it can navigate to the next page.

How should this be accomplished?

Show Answer Hide Answer
Correct Answer: C

To notify the parent component from a child component when a button is clicked:

Option C: Create a custom event

Child Component:

// ChildComponent.js

handleClick() {

const nextEvent = new CustomEvent('next');

this.dispatchEvent(nextEvent);

}

Parent Component:

<!-- ParentComponent.html -->

<c-child-component onnext={handleNext}></c-child-component>

javascript

Copy code

// ParentComponent.js

handleNext() {

// Navigate to the next page

}


'To communicate up the component containment hierarchy, fire a custom event in the child component.' --- Lightning Web Components Developer Guide: Communicate with Events

Why Other Options Are Incorrect:

Option A: Updating a property on the parent directly is not possible from the child.

Option B: 'Fire a notification' is vague and not a standard mechanism.

Option D: Calling a method in the Apex controller does not facilitate child-to-parent communication within components.