U bent hier:
Een Apex klasse maken
Maak een Apex klasse om een e-mail met bijlage te verzenden naar de gebruiker die verzekeringsbewijs aanvraagt.
| VEREISTE EDITIONS |
| Beschikbaar in: Lightning Experience in Professional, Enterprise en Unlimited editions waarin Financial Services Cloud-licentie is ingeschakeld met de uitbreiding FSC Insurance. |
| VEREISTE GEBRUIKERSMACHTIGINGEN | |
| Het serviceproces Verzekeringsbewijs aanvragen instellen: | Sectoren Serviceproces, Sector Service Excellence, Omnistudio, Case, Servicecatalogusaanvraagobjecten Lezen, Maken, Bewerken, Verwijderen, Alle records weergeven EN FSC Verzekering EN Financial Services Cloud-extensie OF FSC Sales OR Financial Services Cloud Basic OR Financial Services Cloud-standaard |
| Als u het serviceproces Verzekeringsbewijs aanvragen wilt gebruiken: | Sectoren Serviceproces, Sector Service Excellence, Omnistudio, Case, Servicecatalogusaanvraagobjecten Lezen, Maken, Bewerken, Verwijderen, Alle records weergeven EN FSC Verzekering EN Financial Services Cloud-extensie OF FSC Sales OR Financial Services Cloud Basic OR Financial Services Cloud-standaard |
- Klik op Set-up en vervolgens op Ontwikkelaarsconsole.
-
Maak een Apex klasse.
Voorbeeld: Als u een e-mailbericht met bijlage wilt verzenden naar de gebruiker die verzekeringsbewijzen aanvraagt, gebruikt u een script als dit:
/************************* * @Class Name:- FSCInsServiceProcessSendEmail * @Description:- This apex class contains an invocable method used to send email along with attachment **************************/ global with sharing class FSCInsServiceProcessSendEmail { // Method to send email along with attachment and reurns either Success or Failure back to flow output variable @InvocableMethod(label='Send Email to user with attachment' description='Sends email to user from apex ') public static List<String> sendEmail(List<Requests> request) { List<Messaging.SingleEmailMessage> mails = new List<Messaging.SingleEmailMessage>(); Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage(); List<String> response = new List<String>(); List<String> sendTo = new List<String> {request[0].sendToEmailId}; mail.setToAddresses(sendTo); mail.setSubject(request[0].emailSubject); mail.setHtmlBody(request[0].textTemplate); //Fetch attachment id associated to the caseId and append it to email as attachments List<Attachment> attList = new List<Attachment> ([SELECT Id, Name FROM Attachment WHERE parentId =: request[0].caseId WITH SECURITY_ENFORCED]); if (attList.size() > 0) { List<String> attachmentIds = new List<String> {attList[0].Id}; mail.setEntityAttachments(attachmentIds); } // Add email to the master list mails.add(mail); //Send all emails in the master list Messaging.SendEmailResult[] results = Messaging.sendEmail(mails); if (results[0].success) { response.add('Success'); } else { response.add('Failed to send email'); } return response; } //set of invocable variables which is used to set values from flow global class Requests { @InvocableVariable(label='Email Body' description='Text template of email body') global String textTemplate; @InvocableVariable(label='Send To Email Id' description='Email id of recipient') global String sendToEmailId; @InvocableVariable(label='CaseId' description='Case Id associated with attachment') global String caseId; @InvocableVariable(label='Email Subject' description='Email subject') global String emailSubject; } }
