Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Optimizing Email Trigger Logic for Large Recipient Lists Without Performance Impact

Nilay_Potdukhe
Tera Contributor

Hi Community,

I’m working on an email notification scenario and need your expert advice to ensure performance optimization and business logic compliance.

Here’s the requirement:

1. Email Trigger Conditions

  • If an email has more than 90 recipients, it should NOT be sent.
  • If an email has more than 60 recipients, same rule applies (no email).
  • The logic should be smooth and not impact performance.

2. Alternative Action

  • If the recipient count is between 50–60 or up to 90, we can send email.
    • A task should be created instead of sending the email. (if possible)
    • The task should go for approval.  (if possible)

3. Additional Rules

  • The same email should not trigger multiple times for different conditions.
  • Approval should be genuine and properly routed.

Goal:

  • Efficient query for recipient count check.
  • Fast processing without performance degradation.
  • Ensure compliance with business rules.

Has anyone implemented something similar?

  • What’s the best approach (BR vs Script Include vs Notification Condition)?
  • Any tips for optimizing the count check logic?

Looking forward to your suggestions!

1 REPLY 1

Mark Manders
Mega Patron

Where is the requirement coming from? Why does it even happen that an email is send to that many people? And why shouldn't it, if it is triggered through some condition? You are going at it from the wrong entry point. You shouldn't check on the number of recipients, but you should check on the notifications and when they are send and to whom. 
Your system is still going to trigger the notification. You are just not sending it. This wins nothing, because you are just setting the email to ignore.
Check your notifications. If they are send to a group that has that many people in it: why is it triggered at all (since you don't want it to go out).

 

Also: what's the difference between your first and second condition? If it shouldn't trigger on >60, your >90 rule is redundant, right?


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark