You need to sign in to do that
Don't have an account?
John Lewis 29
Email-to-Case Identification in Trigger
When a Case is created by Email-to-Case, we find that the CreatedById is set to a special UserId which seems to refer to the Automated Case User 'System' which is configured at Customize > Cases > Support Settings.
I've found that in Apex Trigger code, running for the 'before insert' event on the Case object, this User can be identified by statements such as:
if (UserInfo.getName() == 'System')
if (UserInfo.getUserName().startsWith('automatedcase@'))
if (UserInfo.getUserType() == 'AutomatedProcess')
However, I think that if changes are later made to the Case > Support Settings so that the Automated Case User is an actual User then the above code will no longer give the same result.
Is there, therefore, a reliable way to identify during trigger execution that the Case is being created by Email-to-Case rather than by some other method (manual entry, clone, visualforce, etc.)?
Thanks in advance for any suggestions.
Regards
John Lewis
I've found that in Apex Trigger code, running for the 'before insert' event on the Case object, this User can be identified by statements such as:
if (UserInfo.getName() == 'System')
if (UserInfo.getUserName().startsWith('automatedcase@'))
if (UserInfo.getUserType() == 'AutomatedProcess')
However, I think that if changes are later made to the Case > Support Settings so that the Automated Case User is an actual User then the above code will no longer give the same result.
Is there, therefore, a reliable way to identify during trigger execution that the Case is being created by Email-to-Case rather than by some other method (manual entry, clone, visualforce, etc.)?
Thanks in advance for any suggestions.
Regards
John Lewis
With help of below code snippet, you can find out whether the case is created with help of Email to Case functionality.
Note : ** Please handle bulkification of code by yourself :P
Please select as best answer if it has solved your problem.
Regards,
Virender Singh
I'll let you know how it turns out.
Regards
John Lewis
Regards
John Lewis