我有一些代码,当满足某些条件时,可以通过更新前触发器自动将潜在客户分配到队列。通过 UI 分配潜在客户时,“发送分配通知”复选框可用于指定是否向接收用户(在本例中为队列)发送通知。
l.OwnerId = groups.get('Lead Queue').Id;
这就是我做作业的方式。
通过 Apex 分配时有什么方法可以控制这个吗?似乎默认情况下会发送电子邮件,这会导致队列的所有成员在线索自动分配到队列时都会收到电子邮件,这并不理想。
I have some code that automatically assigns a Lead to a Queue via a before Update trigger when certain conditions are met. When leads are assigned though the UI, the 'Send Assignment Notification' checkbox is available to specify whether or not to send a notification to the receiving user(Queue in this case).
l.OwnerId = groups.get('Lead Queue').Id;
This is how I am doing the assignment.
Is there any way to control this when assigning via Apex? It seems that by default an email is sent, which results in all members of the Queue receiving an email anytime a lead is auto-assigned to the Queue, which is not ideal.
发布评论
评论(2)
您是否尝试过取消选中队列设置页面中的“向成员发送电子邮件”框?也许您出于其他原因需要它,但在我们的组织中,我们在许多队列中取消选中此框,因为我们不需要电子邮件 - 只是所有权。我们使用潜在客户视图、每日报告和针对高优先级潜在客户的自定义潜在客户警报。
我们大量使用 Marketo 来寻找主要分配给区域队列的新潜在客户。我假设他们的代码使用 API 并设置 OwnerId 与您的代码示例非常相似。不过,我们没有看到分配通知电子邮件困扰您的用户,所以我认为这是可能的。
Have you tried unchecking the "Send Email to Members" box in the Queue setup page? Maybe you need it for other reasons, but in our org, we've unchecked this box on many of our queues because we don't want the emails--just ownership. We use lead views, daily reports, and custom lead alerting for high priority leads instead.
We're using Marketo heavily for new leads mostly assigned to territory queues. I assume their code uses the API and sets OwnerId very much like your code example. We're not seeing the assignment notification emails plaguing your users though so I do think it's possible.
我认为您无法抑制分配规则和规则中的电子邮件。 Apex 的工作流程。
电子邮件已发送,因为这是您在分配规则中指定的内容(如果您不提供电子邮件模板,则不会发送 - https://na5.salesforce.com/help/doc/en/creating_assignment_rules.htm(将 na5 替换为您的组织实例)。
但是,如果您要从规则,我认为您仍然有一些选择来处理它:)
您可以构建一个工作流程,在满足条件时发送电子邮件:
AND( OR( ISNEW(), ISCHANGED(OwnerId)), NOT("您的 Apex 标准") )
(您需要在编辑器中设置“如果以下条件运行此规则:公式计算结果为 true”)。
如果“更新前”触发器中的逻辑太复杂而无法被工作流覆盖(例如,因为它跨越多个对象和查询)并且#1将是您的首选选项,您仍然可以这样做。只需在潜在客户中使用一些自定义隐藏字段,并在“更新前”触发器中将其设置为“true”,然后在工作流程中检查此值。
当然,您也可以完全禁用自动分配规则,告诉用户复选框从现在开始将毫无用处,并采用完整的工作流程/完整的触发器解决方案,但我认为这有点太侵入性了。
I don't think you can suppress the emails from assignment rules & workflows with Apex.
Email is sent because that's what you have specified in assignment rule (if you don't provide email template, it's not sent - https://na5.salesforce.com/help/doc/en/creating_assignment_rules.htm (replace na5 with your org instance).
But if you'll remove the email template from the rule, I think you still have some options to deal with it :)
You can build a workflow that will send email when criteria is met:
AND( OR( ISNEW(), ISCHANGED(OwnerId)), NOT("your criteria from Apex") )
(you'll need to set "Run this rule if the following: formula evaluates to true" in editor).
If the logic you have in "before update" trigger is too complex to be covered with workflow (for example because it spans on several objects & queries) and #1 would be your preferred option, you still can do it. Simply use some custom hidden field in Lead and set it to "true" in your "before update" trigger, then check this value in the workflow.
Of course you could also disable the auto assignment rule completely, tell users that checkbox will be useless from now on and go with full workflow/full triggers solution, but that's a bit too invasive I think.