1

Currently, in my Email Send Action, I have more than 30 options in the dropdown to select from Address. This is frustrating for our user who needs to scroll through all lists. I want to limit this from the Address list to 4 or 5.

for this, I have already created one class to override Quick action. I tried to set using fromAddress, but it's not setting. for others like BccAddress, it is working.

sendEmailDefaults.getFromAddressList() is returning a list of all fromaddress, but I don't know how to limit it.

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.Send_Email_Now') && 
               defaults.get(j).getActionType().equals('SendEmail')) {
                   sendEmailDefaults = 
                       (QuickAction.SendEmailQuickActionDefaults)defaults.get(j);
                   break;
            }
        }
        system.debug('>>> sendEmailDefaults... '+sendEmailDefaults);
        if (sendEmailDefaults != null) {
            Case c = [SELECT Status, Reason FROM Case 
                      WHERE Id=:sendEmailDefaults.getContextId()];
        
            EmailMessage emailMessage = (EmailMessage)sendEmailDefaults.getTargetSObject();    
            emailMessage.fromAddress = 'test@abc.com';
            emailMessage.BccAddress = 'test123@abc.com';
            system.debug('>>> fromAddress... '+sendEmailDefaults.getFromAddressList());
            system.debug('>>> emailMessage.fromAddress... '+emailMessage.fromAddress);
            // Set BCC address to make sure each email goes for audit
            //emailMessage.BccAddress = getBccAddress(c.Reason);
            
        }
    }
 
    
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.