You need to sign in to do that
Don't have an account?

An Apex error occurred: System.NullPointerException: Attempt to de-reference a null object in process builder
I have created apex with process builder while doing process it throws error any help me out.
Error Occurred: An Apex error occurred: System.NullPointerException: Attempt to de-reference a null object

Error Occurred: An Apex error occurred: System.NullPointerException: Attempt to de-reference a null object
public class sendAnEmail { @InvocableMethod(label='Test' description='sends an email') public static void sendEmailWithAttachment(List<id> listofQuoteHeader) { Map<Id, Application__c> quotesMap = new Map<Id, Application__c>([SELECT id,Contact__r.Email,Contact__r.Name FROM Application__c WHERE Id IN :listofQuoteHeader]); for(Id QuoteHeaderid :listofQuoteHeader) { PageReference pref= page.PDFGEN; pref.getParameters().put('id',(Id)QuoteHeaderid); pref.setRedirect(true); system.debug('--appID-'+QuoteHeaderid); Attachment attachment = new Attachment(); Blob b=pref.getContentAsPDF(); attachment.Body = b; attachment.Name = Datetime.now().format('yyyy-MM-dd HH:mm') + ' ' + 'Quote' + '.pdf'; attachment.IsPrivate = false; attachment.ParentId = QuoteHeaderid; attachment.Name='Sign.png'; insert attachment; Messaging.SingleEmailMessage semail= new Messaging.SingleEmailMessage(); Messaging.EmailFileAttachment attach= new Messaging.EmailFileAttachment(); attach.setFileName('AttachmentEmailFile.pdf'); attach.setBody(b); semail.setSubject('Quote Issued'); // String[] emailIds= new String[]{'abc@gmail.com'}; String[] emailIds= new String[]{quotesMap.get(QuoteHeaderid)?.Contact__r.Email}; semail.setToAddresses(emailIds); semail.setPlainTextBody('Please find the attached quote details'); semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach}); Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail}); system.debug('----'+listofQuoteHeader); } SendAnEmail.sendAnEmail(); } private static Application__c account; public static void sendAnEmail() { system.debug('--check-'+ApexPages.currentPage().getParameters().get('QuoteHeaderid') ); try{ account = [SELECT Id, Name FROM Application__c WHERE Id = :ApexPages.currentPage().getParameters().get('id')]; } catch (Exception e) { account = new Application__c(); } } public static Application__c getAccount() { return account; } }


Duplicate of https://developer.salesforce.com/forums/ForumsMain?id=9062I000000DIuu

NullPointerException: Attempt to de-reference a null object is very common error in apex class. It occurs when your variable (sobject, list, set or any other data type) is not initialized (allocated memory). ... This error may occur in Apex classes, Visualforce pages with Apex controller, Test classes, Apex Triggers. you can check it via (https://assignmenthelpsaustralia.com/services/assignment-help-melbourne.php)