Apex & .NET Basics|| Map .NET Concepts to the Lightning Platform||Understand Execution Context

Поделиться
HTML-код
  • Опубликовано: 31 окт 2024
  • #trailhead #HandonChallenge
    Link: trailhead.sale...
    Challenge 1: Map .NET Concepts to the Lightning Platform
    Summary: Create an Apex class that returns accounts
    Create an Apex class that returns a List of Account objects for a user-specified state.
    Create an Apex class that contains a static method:
    Name: AccountUtils
    Method name: accountsByState
    The method must return the ID and name of all Account objects that match the BillingState for the state abbreviation passed to the method
    Challenge 2: Understand Execution Context
    Summary: Write an Apex trigger that fires before records are inserted and ensures that the ShippingState field has the same value as the BillingState field.
    Create an Apex class that contains a public static method:
    Name: AccountTriggerHandler
    Method name: CreateAccounts
    The method must accept a List of Account objects
    For each Account record, before saving, ensure that the ShippingState field has the same value as the BillingState field
    Create an Apex Trigger:
    Name: AccountTrigger
    sObject: Account
    Fires: before records are inserted
    Your trigger must call the AccountTriggerHandler.CreateAccounts() method with the collection of new records
    Use the isBefore and isInsert trigger context variables
    Create a test class:
    Name: AccountTriggerTest
    Your test class must insert 200 Account records with a BillingState of CA
    After the insert, test to ensure that all 200 records have a ShippingState of CA
    Before verifying this challenge, run your test class at least once using the Developer Console Run All feature

Комментарии • 9

  • @praveenyarnal6587
    @praveenyarnal6587 4 месяца назад +1

    Thanks bro

  • @trailheadchallenge
    @trailheadchallenge  Год назад +3

    trigger AccountTrigger on Account (before insert)
    {
    if (Trigger.isBefore && Trigger.isInsert) {
    AccountTriggerHandler.CreateAccounts(Trigger.new);
    }
    }

  • @AnithadeviThatithoti
    @AnithadeviThatithoti 4 месяца назад +1

    The Apex class " AccountUtils" is not a legal name sir can you please help me to solve this issue

  • @srinusudha2374
    @srinusudha2374 6 месяцев назад +1

    Executing the 'accountsByState' method on 'AccountUtils' failed. Make sure that you named your method correctly, that it's public and static, and that it accepts a String and returns a List of Account objects.
    sir iam getting this issue can you please help me to solve this issue

  • @trailheadchallenge
    @trailheadchallenge  Год назад +4

    public class AccountTriggerHandler {

    public static void CreateAccounts (List accList)
    {
    for(Account acc : accList)
    {
    if(acc.ShippingState!=acc.BillingState)
    {
    acc.ShippingState = acc.BillingState;
    }
    }
    }
    }

  • @143veeru
    @143veeru Год назад +2

    Getting this error:
    The 'AccountTriggerHandler' class did not achieve 100% code coverage with your test methods. Make sure that you chose 'Run All' tests in the Developer Console at least once before attempting to verify this challenge.

    • @sasankreddy7362
      @sasankreddy7362 Год назад +4

      Save the files and click on test and then click on run all

  • @AnithadeviThatithoti
    @AnithadeviThatithoti 4 месяца назад

    The Apex class " AccountUtils" is not a legal name .sir can you please help to solve this issue

  • @trailheadchallenge
    @trailheadchallenge  Год назад +1

    @isTest
    public class AccountTriggerTest {

    @isTest static void TestCreate200Records(){

    List accts = new List();
    for(Integer i=0; i < 200; i++) {
    Account acct = new Account(Name='Test Account ' + i, BillingState = 'CA');
    accts.add(acct);
    }
    Test.startTest();
    insert accts;
    Test.stopTest();
    System.assertEquals(200, [SELECT Count() FROM Account WHERE ShippingState = 'CA' ]);
    }
    }