• Jacob Brenneman
  • 0 Points
  • Member since 2021

  • Chatter
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
  • 2
Kindly anyone can help on below 4 questions for PD:
thanks in advance

1. Universal Containers has an order system that uses an Order Number to identify an order for customers and service agents.  Order records will be imported into Salesforce
How should the Order Number field be defined in Salesforce?
A. Lookup
B. Direct Lookup
C. Number with External ID – is this the correct answer?
D. Indirect Lookup

2. A developer needs to have records with specific field values in order to test a new Apex class.
What should the developer do to ensure the data is available to the test?

A. use Test.loadData() and reference a CSV file.
B. use SOQL to query the org for the required data.
C. use Test.loadData() and reference a static resource. – is this the correct answer?
D. use Anonymous Apex to create the required data.

3. Which code in a Visualforce page and/or controller might present a security vulnerability?
 A. <apex:outputField value="{!ctrl.userInput}" />

 B. <apex:outputText escape="false" value=" {!$CurrentPage.parameters.userInput}" />

 C. <apex:outputText value="{!£CurrentPage.parameters.userInput}" />   -- is this the correct answer?

 D. <apex:outputField escape="false" value="{!ctrl.userInput}" />

4. A Next Best Action strategy uses an Enhance Element that invokes an Apex method to determine a discount level for a Contact, based on a number of factors.

What is the correct definition of the Apex method?
A. @InvocableMethod
     global static ListRecommendation getLevel(List<ContactWrapper> input)
B. @InvocableMethod
     global static List<List<Recommendation>> getLevel(List<ContactWrapper> input)
     {/*implementation*/}      - Is this the correct answer?
C. @InvocableMethod
     global List<List<Recommendation>> getLevel(List<ContactWrapper> input)
D. @InvocableMethod
     global Recommendation getLevel(ContactWrapper input)

4.  A developer created this Apex trigger that calls
MyClass .myStaticMethod: trigger myTrigger on Contact(before insert) ( MyClass.myStaticMethod(trigger.new, trigger.oldMap); }

The developer creates a test class with a test method that calls MyClass.mystaticMethod, resulting in 81% overall code coverage. What happens when the developer tries to deploy the trigger and two classes to production, assuming no other code exist?

 A. The deployment fails because the Apex trigger has no code coverage. –is this the right answer becuz the test method did not cover the trigger?
 B. The deployment fails because no assertions were made in the test method.
 C. The deployment passes because the Apex code has required (>75%) code coverage.
 D. The deployment passes because both classes and the trigger were included in the deployment.
  • March 25, 2020
  • Like
  • 1
I have this very simple class..  
trigger RestrictContactByName on Contact (before insert, before update) {
    //check contacts prior to insert or update for invalid data
    For (Contact c : Trigger.New) {
        if(c.LastName == 'INVALIDNAME') {   //invalidname is invalid
            c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');
.. and the corresponding Test Class:  
private class TestRestrictContactByName {

	@isTest static void metodoTest() {
		List listaContatti = new List();
		Contact c1 = new Contact(FirstName='Francesco', LastName='Riggio');
		Contact c2 = new Contact(LastName = 'INVALIDNAME');
		//insert listaContatti;
		// Perform test
        Database.SaveResult [] result = Database.insert(listaContatti, false);
		c1.LastName = 'INVALIDNAME';
		update c1;

When I run the Test class from the Developer Console I get 100% of coverage on the RestrictContactByName class but, when I check the challenge on the trailhead it returns the error:

Challenge not yet complete... here's what's wrong: The 'RestrictContactByName' class did not achieve 100% code coverage via your test methods

Has someone had my same issue?