trigger QuoteAttachmentProcessing on Quote (after insert, after update) { Set<Id> quoteIds = new Set<Id>(); if (Trigger.isInsert || Trigger.isUpdate) { for (Quote quote : Trigger.new) { quoteIds.add(quote.Id); } } if (!quoteIds.isEmpty()) { processQuoteAttachments(quoteIds); } public void processQuoteAttachments(Set<Id> quoteIds) { List<Quote> quotesToUpdate = new List<Quote>(); for (Id quoteId : quoteIds) { List<Attachment> quoteAttachments = [SELECT Id, Body FROM Attachment WHERE ParentId = :quoteId]; Boolean isAnyDocumentSigned = false; for (Attachment attachment : quoteAttachments) { Blob attachmentBody = attachment.Body; String pdfContent = attachmentBody.toString(); // Check for initials within the PDF content Boolean hasInitials = checkForInitials(pdfContent); if (hasInitials) { isAnyDocumentSigned = true; break; } } // Update Quote record with overall signature status Quote quoteToUpdate = new Quote(Id = quoteId); quoteToUpdate.Signed_Status__c = isAnyDocumentSigned; quotesToUpdate.add(quoteToUpdate); } if (!quotesToUpdate.isEmpty()) { update quotesToUpdate; } } public Boolean checkForInitials(String pdfContent) { Pattern initialsPattern = Pattern.compile('Initials: ([A-Za-z]{2})'); Matcher matcher = initialsPattern.matcher(pdfContent); return matcher.find(); } }
Standard input is empty
Object: nil error: did not understand #QuoteAttachmentProcessing MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254) UndefinedObject(Object)>>doesNotUnderstand: #QuoteAttachmentProcessing (SysExcept.st:1448) UndefinedObject>>executeStatements (prog:1) Object: nil error: did not understand #insert MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254) UndefinedObject(Object)>>doesNotUnderstand: #insert (SysExcept.st:1448) UndefinedObject>>executeStatements (prog:1) Object: nil error: did not understand #associationAt:ifAbsent: MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254) UndefinedObject(Object)>>doesNotUnderstand: #associationAt:ifAbsent: (SysExcept.st:1448) DeferredVariableBinding>>resolvePathFrom: (DeferBinding.st:115) DeferredVariableBinding>>value (DeferBinding.st:69) UndefinedObject>>executeStatements (prog:10) Object: nil error: did not understand #associationAt:ifAbsent: MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254) UndefinedObject(Object)>>doesNotUnderstand: #associationAt:ifAbsent: (SysExcept.st:1448) DeferredVariableBinding>>resolvePathFrom: (DeferBinding.st:115) DeferredVariableBinding>>value (DeferBinding.st:69) UndefinedObject>>executeStatements (prog:42)
./prog:2: expected expression ./prog:10: expected expression ./prog:42: expected expression