如何设置每天凌晨2点运行的工作流程条件?
我要创建与工作流程规则一起使用的电子邮件警报。
My goal is to set the workflow that runs 2am everyday &&
my custom object field 'startDate' is tomorrow.
基本上每个凌晨 2 点工作流程都会检查我的自定义对象并查看 startDate 是否是明天。
我在工作流程页面查看日期预定义变量,
我看到:
DATE
DATEVALUE
DAY
MONTH
NOW
TODAY
YEAR
对于开始日期,我可以设置条件 startDate = Today() + 1
对于第二个条件,即每天凌晨 2 点
我想不出什么办法。我没有看到 HOUR 变量等。
以前有人这样做过吗?
更新
这可能有效,我必须测试一下。
将 NOW() 日期时间输出更改为字符串(由 TEXT 完成)
从索引 12 开始,向右抓取 2 个字符(由 MID 完成)
这意味着我获取当前时间的小时部分,如果该值等于“02”,则表示
晚上 2 点。
MID(TEXT(NOW()), 12, 2) = '02'
等一下..但是销售人员什么时候检查这个工作流程???
如果他们每天检查一次工作流程,那会是几点?如果检查是在凌晨 2 点之后完成的,那么这个工作流程将永远不会被查看???我有点困惑。
I am to create email alert which works together with workflow rule.
My goal is to set the workflow that runs 2am everyday &&
my custom object field 'startDate' is tomorrow.
Basically every 2am workflow checks my custom object and see if startDate is tomorrow.
I'm at workflow page looking at Date predefined variable,
I see:
DATE
DATEVALUE
DAY
MONTH
NOW
TODAY
YEAR
For the startDate, I can set condition startDate = today() + 1
For second condition which is 2am everyday
I can't think of a way. I don't see HOUR variable etc..
Has anyone done this before?
UPDATE
This might work I have to test though..
Change NOW() datetime output to String (done by TEXT)
Start from index 12 and grab 2 chars to the right (done by MID)
This means I obtained hour part of current time and if the value equals to '02' which means
2am at night.
MID(TEXT(NOW()), 12, 2) = '02'
Wait a sec.. but WHEN does salesforce check this workflow???
If they check workflow once a day, what time it would be? If check is done past 2am, this workflow would never get looked at??? I'm a bit confused.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
工作流程仅在某些事件(对象更新、创建等)上触发。因此,在没有某种触发器的情况下让它在凌晨 2 点运行是不可能的。
技巧是使用 可调度 apex 插入对象(或更新字段)每天凌晨 2 点,并将工作流程设置为在插入/更新时触发。然后,无论您计划的顶点运行什么时间,您的工作流程都会在该对象上启动。
Work flow only triggers on some event (object update, create, etc.). So having it run at 2am without a some sort of trigger is impossible.
The trick is to use schedulable apex to insert an object (or update a field) every day at 2am and set your workflow to trigger on that insert/update. Then your workflow would fire off on that object at whatever time your scheduled apex ran.