この記事は
SalesforceのApexと画面フローで湯婆婆作って遊んでみたので記録。
実行環境
Trailhead Playground
(言語設定が英語なのであしからず)
作ってみる
Apex
渡された文字列からランダムに一文字返すクラスを作る。
RandomCharAction.apxc
public with sharing class RandomCharAction {
@InvocableMethod
public static List<String> getRandomChar(List<String> inputs) {
List<String> result = new List<String>();
for(String input : inputs){
if (String.isEmpty(input)){
result.add('');
} else {
Integer randomIndex = Math.floor(Math.random() * input.length()).intValue();
System.debug(randomIndex);
result.add(input.substring(randomIndex, randomIndex+1));
}
}
System.debug(result);
return result;
}
}
フロー
下準備
- Contactのラベルを「従業員」に変更する。(しなくてもいい)
- Contactにカスタム項目「元の名前」(テキスト型)を作成する。
- ネットから湯婆婆のイイ感じの画像を拾ってきて静的リソースに登録する。
フロー作成
以下、ざっくり各エレメントの説明。
動かしてみる
-
結果画面
名前を付けてくれる。
2_1. ボタンについて
「やり直す」を押下すると名前が入った状態の1の画面が表示される。
「もう一度」を押下すると何も入っていない状態の1の画面が表示される。
2_2. レコード作成について
元の名前と新しい名前が従業員レコードに追加される
参考
- http://arrowhead.blog25.fc2.com/blog-entry-2224.html
- https://help.salesforce.com/s/articleView?id=release-notes.rn_automate_flow_builder_isblank_isempty.htm&release=250&type=5
- https://sf.forum.circlace.com/articles/946417939726065664
- https://trailhead.salesforce.com/ja/trailblazer-community/feed/0D54S00000JeSGLSA3
ローコードの便利さが良くわかった湯婆婆でした。おしまい。