Skip to main content
Stream TDX Bengaluru on Salesforce+. Start learning the critical skills you need to build and deploy trusted autonomous agents with Agentforce. Register for free.

予想時間

BankAcct および CreateContactFromCan クラスを作成する

メモ

メモ

日本語で受講されている方へ
Challenge は日本語の Trailhead Playground で開始し、かっこ内の翻訳を参照しながら進めていってください。Challenge での評価は英語データを対象に行われるため、英語の値のみをコピーして貼り付けるようにしてください。日本語の組織で Challenge が不合格だった場合は、(1) この手順に従って [Locale (地域)] を [United States (米国)] に切り替え、(2) [Language (言語)] を [English (英語)] に切り替えてから、(3) [Check Challenge (Challenge を確認)] ボタンをクリックしてみることをお勧めします。

翻訳版 Trailhead を活用する方法の詳細は、自分の言語の Trailhead バッジを参照してください。

Trail Together の動画

エキスパートの説明を見ながらこのステップを進めて行きたい場合は、Trail Together シリーズの一部である、こちらの動画をご覧ください。

(巻き戻して最初から見直したい場合、このクリップは 08:08 分から開始されます。)

Apex クラスを作成する

BankAcct という名前の Apex クラスを作成します。BankAcct クラスに、balance、acctName、acctType という 3 つの属性を指定します。口座残高を設定するために makeDeposit という名前のメソッドを含めます。

  1. 開発者コンソールで、[File (ファイル)] | [New (新規)] | [Apex Class (Apex クラス)] をクリックします。
  2. [New Apex Class (新規 Apex クラス)] ウィンドウで、BankAcctと入力し、[OK]をクリックします。
  3. [Enter Apex Code (Apex コードを入力)] ウィンドウのコードを次のコードに置き換えます。
    public class BankAcct {
        private integer balance=0;
        public string acctName;
        //Declare a public string attribute named accttype
        public string accttype;
        //Declare a method, named makeDeposit, that accepts an integer named deposit
        //Within the method, add the deposit amount to the balance
        public void makeDeposit (integer deposit) {
        balance = balance + deposit;
        }
        //Declare a method, named getBalance, that returns an integer
        public integer getBalance() {
        //Return the balance attribute
        return balance;
        }
    }
  4. [File (ファイル)] | [Save (保存)] をクリックします。

CreateContactFromCan というクラスと createContact というメソッドを作成します。

  1. [File (ファイル)] | [New (新規)] | [Apex Class (Apex クラス)] をクリックします。
  2. [New Apex class (新規 Apex クラス)] ウィンドウで、CreateContactFromCanと入力し、[OK]をクリックします。
  3. [Enter Apex Code (Apex コードを入力)] ウィンドウのコードを次のコードに置き換えます。
    public with sharing class CreateContactFromCan {
        public void createContact(){
        }
    }
  4. CreateContactFromCan クラスを保存します。

ステップを確認

+100 ポイント

この プロジェクト は各自のハンズオン組織で実行します。[起動] をクリックして開始するか、組織の名前をクリックして別の組織を選びます。

Salesforce ヘルプで Trailhead のフィードバックを共有してください。

Trailhead についての感想をお聞かせください。[Salesforce ヘルプ] サイトから新しいフィードバックフォームにいつでもアクセスできるようになりました。

詳細はこちら フィードバックの共有に進む