function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Biswajit ChinaraBiswajit Chinara 

Block Case Creation in Salesforce

Hi Team,
Would like to know if there is a way where we can block emails to create cases in Salesforce if it triggered from 3rd party systems lower tenants.

3rd party lower tenant email address are: (xxx represents the domian name.)
Test1@xxx.com
Test2@xxx.com
Test3@xxx.com
Test4@xxx.com
Test5@xxx.com
.
.
Test25@xxx.com

Earlier 3rd party system had only 1 lower tenant email address, hence we wrote a validation rule to block the case creation.
Formula: AND(NOT(ISNULL(SuppliedEmail)),CONTAINS(SuppliedEmail,'Test1@xxx.com'))

Would like to know how to handle bulk the email addresses which changes based on 3rd paty system lower tenants number to block case creation. The common thing is this 3rd party lower tenant is the from address increases based on there tenant name.. Test1, Test2 ...... and ends with their unique domain name 'xxx.com'

Note: We can not put the STARTS with condition because there are other 3rd parties system are there where the email address is strating with Test.. 

A sample code snippet would be helpful.

Thanks !
yogesh_patilyogesh_patil
Use list custom setting to inlude all the below email addresses.

Test1@xxx.com
Test2@xxx.com
Test3@xxx.com
Test4@xxx.com
Test5@xxx.com
.
.
Test25@xxx.com

In the EmailMessageHandler (Apex class invoked on trigger of Email Service), you will be obtain the instance of incoming Email Message. Check if the from Email Address is amongst the values in the custom setting.

If Yes
   do not createCase
else 
    createCase
Biswajit ChinaraBiswajit Chinara
Hi Yogesh,
Thanks for your suggestion. While exploring solution got another workaround for the same using REGEX. Performing test scenarios with third party for our approach.
REGEX( SuppliedEmail,"^Test\\d+@xxx\\.com$")

Thanks,
Biswajit