この文章は Salesforce 機械翻訳システムを使用して翻訳されました。詳細はこちらをご参照ください。
英語に切り替える
Clouds with binary code floating aboveCloud with binary code floating above

No Results

Search Tips:

  • Please consider misspellings
  • Try different search keywords

ステップ 2: 基本となるクラスメソッドを作成する

Warehouse アプリケーションでは現在、ユーザが手動で請求書の品目ごとに品目番号を入力する必要があります。これは、ユーザの不注意やレコードの削除によって番号が順不同になる可能性があるため、最適な方法ではありません。

ワークフロールールなどの宣言型ツールを使用してこの問題を解決する方法はないため、このチュートリアルでは、特定の請求書のすべての品目番号を自動的に採番し直す Apex クラスメソッドを作成する方法について説明します。目標は、すべての請求書に含まれる一連の品目に 1 から 1 ずつ増加する連続番号 (1、2、3 ...) が付けられるようにすることです。

最初に、作成するクラスメソッドの基本として、名前、受け入れるパラメータ、コール元の環境に返す値、必要に応じて疑似コードなどを決定して、大まかな実装計画を示します。
  • 開発者コンソールで、Apex クラスを次のコードと同じになるように変更し、[File (ファイル)] | [Save (保存)] をクリックします。

ソースコードについては、https://gist.github.com/3605633を参照してください。

1public class InvoiceUtilities {
2   // Class method to renumber Line Items for a given Invoice number. 
3   // Returns a string that indicates success or failure. 
4   public static String renumberLineItems(String invoiceName) {
5
6      // Create a copy of the target Invoice object and its Line Items. 
7
8      // Loop through each Line Item, re-numbering as you go 
9
10      // Update the Line Items in one transaction, rollback if any problems 
11      // and return error messages to the calling environment. 
12
13      // On success, return a message to the calling program. 
14   }
15}