Package com.veeva.vault.app.qualityone.sdk.api.coaemailintake


package com.veeva.vault.app.qualityone.sdk.api.coaemailintake
This package provides interfaces to implement custom QualityOne COA Email Intake Handlers. QualityOne COA Email Intake Handlers extract details from email attachments to create COA Inspection records. Learn more about setting up Automated COA Email Intake in Vault Help.

To implement and deploy a custom QualityOne COA Email Intake Handler, see QualityOne QMS in Vault Java SDK Overview for more details.

Example

The following is a simplified example of a custom QualityOne COA Email Intake Handler:

 
 package com.veeva.vault.custom.coaemailintakehandlers;

@QualityOneCoaEmailIntakeHandlerInfo(inboundEmailAddress = "my_inbound_email_address__c")
 public class EmailIntakeHandler implements QualityOneCoaEmailIntakeHandler {

     @Override
     public QualityOneCoaEmailIntakeHandlerResponse execute(QualityOneCoaEmailIntakeHandlerContext context) {
         List<QualityOneEmailAttachment> emailAttachments = context.getEmailAttachments();
         List<QualityOneEmailAttachment> excludedAttachments = VaultCollections.newList();

         // Exclude attachments that are less than 1MB
         for (QualityOneEmailAttachment emailAttachment : emailAttachments) {
             if (emailAttachment.getFileSize() < (long) 1024 * 1024) {
             excludedAttachments.add(emailAttachment);
             }
         }

         // Get the Inspection Plan value from the email subject
         String inspectionPlan = context.getEmailSubject();

         // Build an Intake Inspection that defines the created Inspection record
         QualityOneIntakeInspection intakeInspection = context.newIntakeInspectionBuilder()
             .withValue("inspection_plan__v", inspectionPlan)
             .build();

         return context.newCoaEmailIntakeProcessorResponseBuilder()
             .withIntakeInspection(intakeInspection)
             .withExcludedAttachments(excludedAttachments)
             .build();
     }
     
 }