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
Justin LeungJustin Leung 

Running Apex code when Email Quick Action is opened

We're currently moving to Case Feeds, and I'm trying to replace our Send Email (custom button) with the Email quick action.  

The Send Email button runs Javascript code that calls Apex code which populates a merge field (Articles) with the Article Title and Article URL of each article that's attached to the case so it can be used in email templates.

Ideally, we could create a trigger on CaseArticle to popualte this field whenver an article is attached, but I already know that CaseArticle doesn't support triggers (https://success.salesforce.com/ideaView?id=08730000000izXWAAY).

We've tried to add an Email Quick Action Publisher Loader (Support Settings > Enable Default Email Templates or the Default Handler for Email Action).  The code itself works well, but the problem is that this loader only seems to load once when you load the case.  The scenario it does not capture is:
1. Browse a case in the service console
2. In the KnowledgeOne sidebar, attach an article to the case
3. Click the Email quick action
4. Select an email template containing this merge field
5. The merge field is not populated with the article that was just attached

Can anyone confirm the Email Publisher Loader only loads once when the case is loaded, or if there's different timing (hopefully something configurable)?

Any other ideas on how we can populate this merge field between the time the article is attached and when someone selects the Email quick action?

 
Justin LeungJustin Leung
Alternatively, is there some way to tap into when the Service Console refreshes.  For example, if you attach an article from the KnowledgeOne widget, it immediately updates the main case frame in the console.  Is there some way to tap into that refresh to run code?