You need to sign in to do that
Don't have an account?
Ido Greenbaum 10
Help with setting Email TO address in customized Email Publisher Quick Action
Hey all,
I have a running implementation of a customized Email Publisher in the Case Feed, which implement QuickActionDefaultHandler to pre-populate Email Templates based on my Cases Record Type. Below is the Apex Class:
In addition, I am setting the TO address according a combination of the Case Contact and the custom field - 'Additional_To__c'. The above solution is setting the TO properly, but when the Case Contact does exist in the 'Additional_To__c' as follows:
The outcome is a duplicity of the Case Contact - 'test@test.com':
How can I change the IF statement to avoid the above duplicitity?
I have a running implementation of a customized Email Publisher in the Case Feed, which implement QuickActionDefaultHandler to pre-populate Email Templates based on my Cases Record Type. Below is the Apex Class:
global class EmailPublisherLoader implements QuickAction.QuickActionDefaultsHandler { // Empty constructor global EmailPublisherLoader() { } // The main interface method global void onInitDefaults(QuickAction.QuickActionDefaults[] defaults) { QuickAction.SendEmailQuickActionDefaults sendEmailDefaults = null; // Check if the quick action is the standard Case Feed send email action for (Integer j = 0; j < defaults.size(); j++) { if (defaults.get(j) instanceof QuickAction.SendEmailQuickActionDefaults && defaults.get(j).getTargetSObject().getSObjectType() == EmailMessage.sObjectType && defaults.get(j).getActionName().equals('Case.Email') && defaults.get(j).getActionType().equals('Email')) { sendEmailDefaults = (QuickAction.SendEmailQuickActionDefaults)defaults.get(j); break; } } if (sendEmailDefaults != null) { Case c = [SELECT Status, contact.Email, Additional_To__c, Additional_CC__c, Additional_BCC__c, RecordType.name FROM Case WHERE Id=:sendEmailDefaults.getContextId()]; EmailMessage emailMessage = (EmailMessage)sendEmailDefaults.getTargetSObject(); //set TO address if (c.contact.Email == c.Additional_To__c){ emailMessage.toAddress = (c.contact.Email); } else{ if (c.Additional_To__c != null){ emailMessage.toAddress = (c.contact.Email+' '+c.Additional_To__c); } }
In addition, I am setting the TO address according a combination of the Case Contact and the custom field - 'Additional_To__c'. The above solution is setting the TO properly, but when the Case Contact does exist in the 'Additional_To__c' as follows:
The outcome is a duplicity of the Case Contact - 'test@test.com':
How can I change the IF statement to avoid the above duplicitity?
Please find below post which was addressed in the stack exchange community.
I was able to resolve this by using 'indexOf' for String 'includes' condition as follows:
Please mark this post as solved so that it gets removed from unanswered queue and will be available as proper solution so that other can benefit from this.
Regards,
Nagendra.P
All Answers
Please find below post which was addressed in the stack exchange community.
I was able to resolve this by using 'indexOf' for String 'includes' condition as follows:
Please mark this post as solved so that it gets removed from unanswered queue and will be available as proper solution so that other can benefit from this.
Regards,
Nagendra.P
Thanks for the assistance.
As far as I know My below code is correct.
Here is the place where im passing the value for FROM Address fields.
Here is the Email publisher action page. See, all oher fields are populated as per Apex definition. From address is only considering the ORG WIDE ADDRESS.
Here is my full APEX code: