Apex InvocableMethod アノテーションの使い方のサンプル
環境
Salesforce Apex
概要
InvocableMethod アノテーション
呼び出し可能なアクションとして実行できるメソッドを識別するには InvocableMethod アノテーションを
使用します。
呼び出し可能なメソッドは、REST API でコールされ、1 つの Apex メソッドを呼び出すために使用します。呼び
出し可能なメソッドには動的な入力値と出力値があり、記述用の API コール (describe) をサポートします。
使用例
public class AccountQueryAction {
@InvocableMethod(label='Get Account Names' description='Returns the list of account names
corresponding to the specified account IDs.')
public static List<String> getAccountNames(List<ID> ids) {
List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
for (Account account : accounts) {
accountNames.add(account.Name);
}
return accountNames;
}
}
public class AccountQueryAction {
@InvocableMethod(label='Get Account Names' description='Returns the list of account names
corresponding to the specified account IDs.')
public static List<String> getAccountNames(List<ID> ids) {
List<String> accountNames = new List<String>();
List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids];
for (Account account : accounts) {
accountNames.add(account.Name);
}
return accountNames;
}
}
public class AccountQueryAction { @InvocableMethod(label='Get Account Names' description='Returns the list of account names corresponding to the specified account IDs.') public static List<String> getAccountNames(List<ID> ids) { List<String> accountNames = new List<String>(); List<Account> accounts = [SELECT Name FROM Account WHERE Id in :ids]; for (Account account : accounts) { accountNames.add(account.Name); } return accountNames; } }