
本日のTips!は、標準のフローだけを使って、開発なし(ノンコーティング)で休日を判定し、平日だけ処理を実行する方法をご紹介します。
お客様の業務を自動化する場合に、平日だけ処理を実行したいというご要望がよくありますが、この方法を使えば簡単に実現することができますので、是非マスターしてください。
※祝日も判定して営業日だけ処理をする方法については、最後にご紹介いたします。
例えば、平日の毎朝8時に期日切れタスクがあるかチェックして、期日超過がある場合には担当者へメール通知するなどの用途があります。
- フロービルダーによるスケジュールトリガーフローの作成方法
- フローを使った週末(土曜日・日曜日)の判定方法
1.フロービルダーを使って週末を判定してみよう
今回は、スケジュールトリガーフローを使って、曜日を判定する処理を作成してみます。もちろんスケジュールトリガー以外のフローでも構いません。
大まかな処理の流れは以下の通りです。
- フロー実行日を使って曜日を判断する変数を定義
- 曜日の変数を条件にして条件分岐処理を作成
- デバッグ実行
- フローの有効化とスケジュール設定
では、一つ一つ手順の内容を解説していきたいと思います。
1.フローの実行日を使って曜日を判断する変数を定義
1.Salesforceにログインして、[設定] からクイック検索で[フロー]を検索して実行します。
[新規フロー]のボタンをクリックして、新規フロー作成画面を開きます。
2.新規フロー画面では、スケジュールトリガーフローを選択します。
作成方法で表示される自由形式と自由レイアウト(Beta)はどちらでもお好きなものを選択してください。
3.スケジュールを設定をクリックして、スケジュール設定画面を表示します。
①開始日と開始時間を入力します。指定された開始日、開始時間でスケジュールが起動します。
※開始時間は、組織のタイムゾーンの時間で実行されます。
組織のタイムゾーンが海外になっている場合、日本の時間で設定すると期待した時間に動作しないため注意が必要となります。
②頻度を指定します。※今回は週末判定のテストフローを作成し、デバッグ実行で確認するだけのため、1回のみとします。
4.新規リソースをクリックし、曜日を判定するための変数を定義します。
リソース種別:数式 API参照名、説明:自由に定義してください。
データ型:数値 ※少数は0としてください。
数式は以下の内容を設定します。
MOD( {!$Flow.CurrentDate} – DATE(1900, 1, 7), 7)
上記数式により、フロー実行日の曜日が以下の0~6の数値で判定されます。
- 0:日曜日
- 1:月曜日
- 2:火曜日
- 3:水曜日
- 4:木曜日
- 5:金曜日
- 6:土曜日
2.曜日の変数を条件にして条件分岐処理を作成
1.続いて、要素を追加から、ロジック[決定]をクリックして、週末判定のロジックを作成します。
2.週末(土曜日・日曜日)を判定する処理を以下の内容で作成します。
結果:週末(土日) 表示ラベル:週末(土日) API名は自由に定義ください。
結果を実行する条件の要件:いずれかの条件に一致(OR)を選択し以下2つの条件を追加
- リソース:DayOfTheWeekDecimal 演算子:次の文字列と一致しない 値:0
- リソース:DayOfTheWeekDecimal 演算子:次の文字列と一致しない 値:6
曜日判定の数式を使って、フロー実行日が0(日曜日)、または6(土曜日)のどちらかの場合は、週末(土日)と判断します。
もう一方のデフォルトの結果に関しては、ラベルを平日と定義 ※ロジックは不要
3.営業日を最終的に判断するための新規リソースを追加して、以下の変数を定義します。
変数名:BusinessDayFlag (ご自由に定義してください)
データ型:Boolean デフォルト値:{!GlobalConstant.True} ※グローバル変数のTrueをセット(Trueで検索すると候補に表示されます)
4.週末判定処理の分岐で、週末判定された場合の後続フローで以下のロジック[割り当て]を定義します。
※週末の場合に、3.で作成した週末変数フラグにTrueをセットします。
変数:BusinessDayFlag 演算子:次の文字列と一致する 値:Global変数のFalseをセット
5.週末判定ロジックの完了
最終的に以下のようなフローが作成されます。
上記サンプルでは、スケジュール実行時の日付を使って、週末(土日)の判定が行われます。
週末判定処理の平日の後続フローに実行したい処理やサブフローの呼び出しを定義することで平日だけ処理を行うことができます。
また、今回のサンプルでは、1回だけの繰り返しとしましたが、スケジュールを毎日繰り返し処理として定義すれば平日の日次処理を作成することができます。
3.デバッグ実行
1.フローを保存したあと、デバッグボタンをクリックします。
フローをデバッグの画面が表示されます。今回作成したフローは特に処理を入れていないためロールバックの必要はありませんが、
データを作成したりするような処理がある場合は、ロールバックオードを利用して既存データに影響しないように実行することもできます。
2.実行結果の確認
デバッグ実行すると処理結果の詳細を確認することができます。上記ではご説明していませんが、以下の図の最後に表示されているような変数の値などを表示するメモを追加するとデバッグしやすくなりますので、ぜひお試しください。
※処理の最後にメモなどのアクションを定義するだけです。
4.フローの有効化とスケジュール設定
1.デバッグ実行で問題がなければ、上記で作成したフローを保存した後、有効化ボタンをクリックしてください。
2.フローを有効化すると、スケジュール済みジョブに実行計画が登録されます。
例では、2月14日の21:45に次回実行される予定で登録されています。
※スケジュールを変更したい場合は、フローのスケジュールを変更して保存後、有効化することで新しいスケジュールに変更することができます。
サンプルフロー(メタデータ)
本記事でご紹介したフローのメタデータを公開します。
<?xml version="1.0" encoding="UTF-8"?>
<Flow xmlns="http://soap.sforce.com/2006/04/metadata">
<actionCalls>
<name>DebugMemo</name>
<label>営業日判定結果</label>
<locationX>358</locationX>
<locationY>1164</locationY>
<actionName>NewNote</actionName>
<actionType>quickAction</actionType>
<inputParameters>
<name>Title</name>
<value>
<stringValue>営業日判定</stringValue>
</value>
</inputParameters>
<inputParameters>
<name>Body</name>
<value>
<stringValue>日付:{!$Flow.CurrentDate} 曜日判定:{!DayOfTheWeekDecimal} 営業日判定:{!BusinessDayFlag}</stringValue>
</value>
</inputParameters>
</actionCalls>
<apiVersion>50.0</apiVersion>
<assignments>
<name>SetBusinessDayFlagFalse</name>
<label>営業日フラグにFalseをセット</label>
<locationX>50</locationX>
<locationY>396</locationY>
<assignmentItems>
<assignToReference>BusinessDayFlag</assignToReference>
<operator>Assign</operator>
<value>
<booleanValue>false</booleanValue>
</value>
</assignmentItems>
<connector>
<targetReference>DebugMemo</targetReference>
</connector>
</assignments>
<assignments>
<name>SetBusinessDayFlagFalse_0</name>
<label>営業日フラグにFalseをセット</label>
<locationX>754</locationX>
<locationY>756</locationY>
<assignmentItems>
<assignToReference>BusinessDayFlag</assignToReference>
<operator>Assign</operator>
<value>
<booleanValue>false</booleanValue>
</value>
</assignmentItems>
<connector>
<targetReference>LoopHolidayRecords</targetReference>
</connector>
</assignments>
<decisions>
<description>祝日判定処理</description>
<name>ConditionJudgementHolidays</name>
<label>祝日判定処理</label>
<locationX>886</locationX>
<locationY>636</locationY>
<defaultConnector>
<targetReference>LoopHolidayRecords</targetReference>
</defaultConnector>
<defaultConnectorLabel>営業日</defaultConnectorLabel>
<rules>
<name>IsHoliday</name>
<conditionLogic>and</conditionLogic>
<conditions>
<leftValueReference>$Flow.CurrentDate</leftValueReference>
<operator>EqualTo</operator>
<rightValue>
<elementReference>LoopHolidayRecords.ActivityDate</elementReference>
</rightValue>
</conditions>
<connector>
<targetReference>SetBusinessDayFlagFalse_0</targetReference>
</connector>
<label>祝日</label>
</rules>
</decisions>
<decisions>
<description>週末(土日)判定処理
0:日曜日、6:土曜日</description>
<name>ConditionJudgementIsWeekend</name>
<label>週末(土日)判定処理</label>
<locationX>358</locationX>
<locationY>276</locationY>
<defaultConnector>
<targetReference>GetOrgHolidayRecords</targetReference>
</defaultConnector>
<defaultConnectorLabel>平日</defaultConnectorLabel>
<rules>
<name>IsWeekend</name>
<conditionLogic>or</conditionLogic>
<conditions>
<leftValueReference>DayOfTheWeekDecimal</leftValueReference>
<operator>NotEqualTo</operator>
<rightValue>
<numberValue>0.0</numberValue>
</rightValue>
</conditions>
<conditions>
<leftValueReference>DayOfTheWeekDecimal</leftValueReference>
<operator>NotEqualTo</operator>
<rightValue>
<numberValue>6.0</numberValue>
</rightValue>
</conditions>
<connector>
<targetReference>SetBusinessDayFlagFalse</targetReference>
</connector>
<label>週末(土日)</label>
</rules>
</decisions>
<formulas>
<description>曜日判定のための変数</description>
<name>DayOfTheWeekDecimal</name>
<dataType>Number</dataType>
<expression>MOD( {!$Flow.CurrentDate} - DATE(1900, 1, 7), 7)</expression>
<scale>0</scale>
</formulas>
<interviewLabel>営業日判定フロー {!$Flow.CurrentDateTime}</interviewLabel>
<label>営業日判定フロー</label>
<loops>
<name>LoopHolidayRecords</name>
<label>祝日分繰り返し処理 (LoopHolidayRecords)</label>
<locationX>666</locationX>
<locationY>516</locationY>
<collectionReference>GetOrgHolidayRecords</collectionReference>
<iterationOrder>Asc</iterationOrder>
<nextValueConnector>
<targetReference>ConditionJudgementHolidays</targetReference>
</nextValueConnector>
<noMoreValuesConnector>
<targetReference>DebugMemo</targetReference>
</noMoreValuesConnector>
</loops>
<processMetadataValues>
<name>BuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>CanvasMode</name>
<value>
<stringValue>AUTO_LAYOUT_CANVAS</stringValue>
</value>
</processMetadataValues>
<processMetadataValues>
<name>OriginBuilderType</name>
<value>
<stringValue>LightningFlowBuilder</stringValue>
</value>
</processMetadataValues>
<processType>AutoLaunchedFlow</processType>
<recordLookups>
<name>GetOrgHolidayRecords</name>
<label>組織の休日レコード取得</label>
<locationX>666</locationX>
<locationY>396</locationY>
<assignNullValuesIfNoRecordsFound>false</assignNullValuesIfNoRecordsFound>
<connector>
<targetReference>LoopHolidayRecords</targetReference>
</connector>
<getFirstRecordOnly>false</getFirstRecordOnly>
<object>Holiday</object>
<storeOutputAutomatically>true</storeOutputAutomatically>
</recordLookups>
<start>
<locationX>232</locationX>
<locationY>0</locationY>
<connector>
<targetReference>ConditionJudgementIsWeekend</targetReference>
</connector>
<schedule>
<frequency>Once</frequency>
<startDate>2021-02-14</startDate>
<startTime>00:00:00.000Z</startTime>
</schedule>
<triggerType>Scheduled</triggerType>
</start>
<status>Active</status>
<variables>
<description>平日判定フラグ</description>
<name>BusinessDayFlag</name>
<dataType>Boolean</dataType>
<isCollection>false</isCollection>
<isInput>true</isInput>
<isOutput>true</isOutput>
<value>
<booleanValue>true</booleanValue>
</value>
</variables>
</Flow>
上記、このソースの前半部分が平日判定の内容となります。
まとめ

いかがでしたでしょうか。説明した手順で設定はうまくいきましたか?
今回は、週末を判定するだけでしたが、週末及び祝日を判定して営業日だけ処理を実行する方法もあります。
そのやり方は、以下の記事で紹介していますので、興味があればご覧ください
















You really make it seem so easy along with your presentation but I to find this matter to be really
one thing that I feel I would never understand.
It kind of feels too complex and extremely vast for me.
I am looking forward on your next post, I will try to get the
hang of it! Escape rooms
I like this site it’s a master piece! Glad I observed this on google.?
Everything is very open with a very clear clarification of the challenges. It was really informative. Your site is very helpful. Thanks for sharing.
Great blog you have here.. It’s difficult to find good quality writing like yours these days. I seriously appreciate people like you! Take care!!
Oh my goodness! Incredible article dude! Thank you so much, However I am encountering issues with your RSS. I don’t understand the reason why I am unable to subscribe to it. Is there anyone else having the same RSS problems? Anyone who knows the solution will you kindly respond? Thanx!!
It’s hard to find knowledgeable people about this subject, however, you sound like you know what you’re talking about! Thanks
This site definitely has all the information and facts I needed concerning this subject and didn’t know who to ask.
Good post. I learn something totally new and challenging on websites I stumbleupon every day. It’s always useful to read through articles from other authors and practice something from their websites.
Bu casino’nun sunduğu slot oyunları gerçekten büyük kazanç fırsatları sunuyor.
Casino’nun sunduğu bonuslar ile slot oyunlarında daha fazla kazanmaya başladım.
Bahis siteleri deneme bonusu ile oyunlara sıfır yatırım yaparak büyük ödüller kazandım!
It’s hard to find experienced people for this subject, however, you seem like you know what you’re talking about! Thanks
Next time I read a blog, I hope that it doesn’t fail me as much as this particular one. I mean, Yes, it was my choice to read through, however I truly thought you’d have something interesting to say. All I hear is a bunch of moaning about something you could fix if you weren’t too busy seeking attention.
Deneme bonusu sayesinde crash oyunlarında, özellikle Aviator’da, risksiz oynayarak kazanç sağlıyorum!
You need to be a part of a contest for one of the highest quality sites online. I most certainly will highly recommend this web site!
Bahis sitelerinde deneme bonusu almak, kazanmaya başlamak için mükemmel bir yol!
I’m amazed, I must say. Seldom do I encounter a blog that’s both educative and amusing, and without a doubt, you’ve hit the nail on the head. The issue is something which too few men and women are speaking intelligently about. I’m very happy that I came across this during my hunt for something concerning this.
Bahis siteleri deneme bonusu ile oyunlara sıfır yatırım yaparak hemen kazanmaya başladım!
Bu casino’daki jackpot slot oyunları ile büyük ödüller kazanmak çok eğlenceli.
Casino’nun sunduğu turnuvalar ile ekstra kazançlar kazanmak çok eğlenceli ve kazançlı!
Bu casino’da en yüksek kazancı Mega Moolah slot oyunundan elde ettim.
Yüksek bahislerle oynadığım futbol bahislerinde devasa ödüller kazanıyorum!
Casino’nun sunduğu bonuslar bahislerimi daha kazançlı hale getiriyor, her oyun bir fırsat!
This excellent website certainly has all the information I needed concerning this subject and didn’t know who to ask.
Bu casino’daki jackpot slot oyunları ile büyük ödüller kazanmak çok eğlenceli.
En sevdiğim slot oyunu Wolf Gold, grafikler harika ve kazançlar çok yüksek!
Pretty! This was an incredibly wonderful post. Thanks for providing this info.
Yüksek bahislerimle Starburst slotunda devasa kazançlar elde ediyorum!
Yüksek bahislerle oynadığımda Sweet Bonanza slotunda devasa kazançlar kazanıyorum!
Aw, this was a very good post. Taking a few minutes and actual effort to generate a top notch article… but what can I say… I hesitate a lot and never seem to get anything done.
Bu casino’daki futbol bahis seçenekleri ile her maç daha da kazançlı hale geliyor!
This blog was… how do you say it? Relevant!! Finally I’ve found something which helped me. Appreciate it.
Bu casino’da slot oyunları oynayarak her gün kazanç elde ediyorum, herkes denemeli!
Bu casino’daki slot oyunlarında kazanç elde etmek çok kolay ve eğlenceli.
This is a topic that is close to my heart… Cheers! Exactly where are your contact details though?
Casino’nun sunduğu bonuslar futbol bahislerinde ekstra avantaj sağlıyor, her maçta kazanç fırsatları yaratıyor.
Greetings, I do believe your website may be having internet browser compatibility problems. Whenever I take a look at your website in Safari, it looks fine however when opening in Internet Explorer, it has some overlapping issues. I just wanted to provide you with a quick heads up! Besides that, excellent blog.
En sevdiğim slot oyunu Razor Shark, grafikler harika, kazançlar büyük!
Your style is so unique in comparison to other people I’ve read stuff from. Thank you for posting when you have the opportunity, Guess I’ll just book mark this blog.
En sevdiğim slot oyunu Great Rhino Megaways, kazançlarım her geçen gün artıyor.
Oh my goodness! Impressive article dude! Many thanks, However I am going through issues with your RSS. I don’t know why I can’t join it. Is there anybody having identical RSS issues? Anybody who knows the answer can you kindly respond? Thanx.
Hello there! This post could not be written any better! Looking through this post reminds me of my previous roommate! He always kept talking about this. I am going to send this post to him. Fairly certain he’s going to have a great read. I appreciate you for sharing!
Casino’nun sunduğu promosyonlar sayesinde futbol bahislerinde ekstra avantaj sağlıyorum!
Bu casino’daki slot oyunları ile her gün büyük kazançlar elde ediyorum, şansımı denemeye devam ediyorum.
Bahis siteleri deneme bonusu ile oyunlara sıfır yatırımla başlayarak büyük kazançlar sağlıyorum!
Casino’nun sunduğu promosyonlar sayesinde slot oyunlarında şansım hep açık!
Bahis sitelerinde deneme bonusu ile oyunlara bedava başlayarak kazanabilirsiniz!
Spot on with this write-up, I actually feel this web site needs a lot more attention. I’ll probably be returning to read more, thanks for the advice!
Deneme bonusu ile Aviator oynarken riske girmeden büyük kazançlar elde ediyorum!
Bu casino’nun sunduğu canlı bahis seçenekleri futbol maçlarını izlerken ekstra kazanç fırsatları yaratıyor!
Bu casino’nun sunduğu slot oyunlarında jackpot kazanmak gerçekten mümkün!
Düşük bahislerle futbol maçlarına oynarken bile sürekli kazanç elde ediyorum!
Bu casino’daki slot oyunları ile büyük ödüller kazanmak gerçekten mümkün.
Incorporating Sugar Protector into my daily regimen has been a game-changer for my overall health.
As a person that currently focuses on healthy and balanced eating, this
supplement has actually offered an added increase of protection. in my energy degrees,
and my wish for undesirable treats so easy can have such an extensive impact on my
daily life.
Incorporating Sugar Protector into my day-to-day regimen has actually been a game-changer for my general wellness.
As somebody that currently focuses on healthy and balanced eating, this supplement has offered an added
boost of defense. in my energy degrees, and my wish for harmful
treats so easy can have such an extensive influence on my every day life.
Uncovering Sugar Defender has actually been a game-changer for me, as
I have actually always been vigilant regarding managing my blood sugar levels.
I currently really feel encouraged and confident in my ability to preserve
healthy and balanced degrees, and my most current checkup have actually reflected this progress.
Having a trustworthy supplement to complement my a significant source of comfort, and I’m truly glad for
the substantial distinction Sugar Defender has made in my general health.
Integrating Sugar Defender into my daily routine has been a game-changer for my total health.
As someone who already focuses on healthy eating, this supplement has actually provided an included
boost of protection. in my power degrees, and my need for harmful snacks so easy can have such a profound effect on my every day life.
Uncovering Sugar Defender has actually been a game-changer
for me, as I’ve always been vigilant regarding managing
my blood sugar levels. With this supplement, I feel equipped to take charge of my
wellness, and my latest clinical exams have actually reflected
a significant turnaround. Having a credible ally in my corner supplies me with a complacency
and peace of mind, and I’m deeply happy for the extensive difference Sugar Protector has made in my well-being.
I blog often and I seriously thank you for your information. The article has truly peaked my interest. I will book mark your blog and keep checking for new information about once a week. I opted in for your Feed too.
You are so interesting! I don’t think I’ve read through anything like that before. So good to find another person with genuine thoughts on this issue. Really.. thank you for starting this up. This website is one thing that’s needed on the internet, someone with a bit of originality.
Very nice article. I absolutely love this website. Continue the good work!
Hi there! Do you know if they make any plugins to assist with Search Engine
Optimization? I’m trying to get my website to rank for some targeted keywords but I’m not seeing very
good results. If you know of any please share. Thanks! You can read similar article here:
Eco wool
Hello! I could have sworn I’ve been to your blog before but after going through a few of the posts I realized it’s new to me. Regardless, I’m definitely pleased I stumbled upon it and I’ll be bookmarking it and checking back regularly!
I absolutely love your website.. Very nice colors & theme. Did you make this site yourself? Please reply back as I’m looking to create my own website and would love to learn where you got this from or what the theme is called. Thanks.
Spot on with this write-up, I seriously think this web site needs a lot more attention. I’ll probably be returning to see more, thanks for the information.
Greetings! Very useful advice within this article! It’s the little changes which will make the most important changes. Thanks for sharing!