• chikku
  • NEWBIE
  • 80 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 37
    Questions
  • 21
    Replies
I have created the data table and the last trow should be empty the only the total should display but automatically it assuming like undefined. URL.
I need to set an empty value, any help

User-added image

 
getTransactionWithSummery(dataValues) {
            var totalAmount = 0.00;
            if (dataValues.length > 0) {
                for (var i = 0; i < dataValues.length; i++) {
                    totalAmount += dataValues[i].Amount__c;
                }
              
           dataValues.push({Amount__c: totalAmount.toFixed(2),GuarantorName:'Total'} );
            
           }
            return dataValues;
            
        }



any help ?

it Causing errors while debugging..there any solutions guys.
 
private static  Application__c app{get; private set;}
       public static void   MyController() {
           
           Id id = ApexPages.currentPage().getParameters().get('id');
                  system.debug('--check--'+id);
           try{
                app = (id == null) ? new Application__c() : 
            [SELECT id,Name FROM Application__c WHERE Id = :id];
                
                }catch(System.QueryException e){
            }}
            public static Application__c getapp() {
             return app; 
   }  
 }

 
When I do the process it throws an error on it like this and unable to show merge fields too in pdf.

Error Occurred: An Apex error occurred: System.NullPointerException: Attempt to de-reference a null object

User-added image

 
public class sendAnEmail
{
     
      @InvocableMethod( label='Test' description='sends an email')
       
    public static void sendEmailWithAttachment(List<id> listofQuoteHeader)
    {   
      
        // Application__c applink = [SELECT Id,Name FROM Application__c  ];
        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.setHtmlBody('Hello ' +  + '<br/><br/>Summary report' + contact.Name+'.<br/><br/><a href="'+ URL.getSalesforceBaseUrl().toExternalForm() + '/' + QuoteHeaderid+'">Click Here</a> Please check your Summary report');

               semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
                  system.debug('----'+listofQuoteHeader);
           } 
        
 SendAnEmail.sendAnEmail();// I have call the constructor method in invocable method
    }
    // this method for merge fields
       private static  Application__c app{get; private set;}
       public static void sendAnEmail() {
          
               Id id = ApexPages.currentPage().getParameters().get('id');
                app = (id == null) ? new Application__c() : 
            [SELECT id,Name FROM Application__c WHERE Id = :id];
           }
           
}
<apex:page  controller="sendAnEmail" renderAs="advanced_pdf" applyHtmlTag="false" applyBodyTag="false" standardStylesheets="false"
showHeader="false" sidebar="false">>
   <apex:form >
             You belong to app Name:{!app.Name}
          </apex:form> 
    
     <h1>
    
      hello
    </h1>
  
</apex:page>
please help me out

 
My requirement is I need to add the hyperlink in the pdf attachment in an email.
when they click the links in the email, there should navigate to the current record id. (For example, if I click that link in the email which  I received then that should navigate to contact record page with respective contact id)

It possible guys?
 
I don't know where I made mistake in the apex with process builder help me out
While debugging the error shown in 48 lines of the apex

Error: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.test();
    }
       public Application__c account{get;set;} 
      
    private static  Application__c account;
     public static void test() {
            system.debug('--check-'+ApexPages.currentPage().getParameters().get('QuoteHeaderid') );
            try{
                 if (account != null) 

        account = [SELECT Id, Name  FROM Application__c 
                  Where Id=:ApexPages.currentPage().getParameters().get('Id')];// i think this part shwoing error while debug
               
    }
            catch (Exception e) {
   
    account = new Application__c();
}
        }
        public static Application__c getAccount() {
        return account;
    }

}

User-added image
  • April 30, 2021
  • Like
  • 0
 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
 
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;
    }

}

User-added image
  • April 30, 2021
  • Like
  • 0
I have used the constructor method but it throws an error

Error :  Method does not exist or incorrect signature: void sendAnEmail() from the type sendAnEmail
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 final Application__c account;
        public sendAnEmail() {
            system.debug('--check-'+ApexPages.currentPage().getParameters().get('QuoteHeaderid') );
            try{
        account = [SELECT Id, Name  FROM Application__c 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('QuoteHeaderid')];
               
    }
            catch (Exception e) {
    // add your message to the user or
    account = new Application__c();
}
        }
        public Application__c getAccount() {
        return account;
    }

}

User-added image

 
  • April 30, 2021
  • Like
  • 0
  1. I have the Application__c object with the lookup contact object.
  2. I need to show the Contact name and application Name in pdf which I have created
  3. I have used the Invocable method for sending emails with pdf...
  4. when I do the process it throws an error Like this below:
Error Occurred: common.apex.runtime.impl.ExecutionException: List has no rows for assignment to SObject

But now I unable to show any merged field on my pdf page. There is any resolved solution?
<apex:page controller="sendAnEmail" renderAs="pdf">
   <apex:form >
           You belong to Contact Name:{!account.name} 
             
    </apex:form> 
  <h1>
      hello
    </h1>
</apex:page>
 
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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);
           } }
      
      private final Application__c account;
        public sendAnEmail() {
            system.debug('---'+ApexPages.currentPage().getParameters().get('id') );
        account = [SELECT Id, Name  FROM Application__c 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }
        public Application__c getAccount() {
        return account;
    }

}

User-added image
  • April 30, 2021
  • Like
  • 0
I Am stuck with an error I have created an apex with process bulder.
If I run the process it throws an error.

Error Occurred: common.apex.runtime.impl.ExecutionException: List has no rows for assignment to SObject
 
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
               
           } }
      
      private final Application__c account;
        public sendAnEmail() {
        account = [SELECT Id, Name  FROM Application__c 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }
        public Application__c getAccount() {
        return account;
    }

}

There is any resolved answer
 
  • April 30, 2021
  • Like
  • 0
  1. I have the Application__c object with the lookup contact object.
  2. I need to show the Contact name and application Name in pdf which I have created
  3. I have used apex controller for merged class it doesn't work
But now I unable to show any merged field on my pdf page. There is any resolved solution? it may help others too.
 
<apex:page renderAs="PDF" >
    <h1 >Congratulations </h1 >
Name:Application__c.Contact__r.Nam
 
 </apex:page>
 
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
           }
       
            }
  }

 
  • April 29, 2021
  • Like
  • 0
I have Application__c with Look Contact, I need to show Contact name and Application Name in Pdf attachment as dynamic.
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
           }
       
            }
  }
 
<apex:page renderAs="PDF" >
	<h1 >Congratulations </h1 >
Name:Application__c.Contact__r.Name
 
 </apex:page>

 
  • April 29, 2021
  • Like
  • 0
I need to show the Contact name with Lookup with Application in pdf attachment..
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
           }
       
            }
  }

VF page
 
<apex:page standardController="Application__c" renderAs="pdf">
 <h1>
     Application__c.Contact__r.Name
    </h1>
</apex:page>

 
  • April 29, 2021
  • Like
  • 0
I need to send a dynamic setToAddresses email id with the contact I choose
public class sendAnEmail
{
    
    @InvocableMethod(label='Test' description='sends an email')
    public static void sendEmailWithAttachment(List<id> listofQuoteHeader)
    {
     List<Contact> Con = [SELECT Id, Email FROM Contact ];
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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;
               insert attachment;
               
               Messaging.SingleEmailMessage semail= new Messaging.SingleEmailMessage();
               Messaging.EmailFileAttachment attach= new Messaging.EmailFileAttachment();
               attach.setBody(pref.getContentAsPDF());
               semail.setSubject('Quote Issued');
       String[] emailIds= new String[]{'abc@gmail.com'}; // I need this part has  dynamic based on contact email id
               semail.setToAddresses(emailIds);
               
               semail.setPlainTextBody('Please find the attached quote details');
               semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
               Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
           }
    }
 
}

 
  • April 28, 2021
  • Like
  • 0
  1. I have created a Vf page and apex to send PDF attachments in email.
  2. I have object Apple__c with Lookup Contact
  3. When I create a new Apple record and Particular contact with Email, then email should send to the contact which I have selected.
 
Now I have developed static, I need in dynamic.
public class sendAnEmail
{
    
    @InvocableMethod(label='Test' description='sends an email')
    public static void sendEmailWithAttachment(List<id> listofQuoteHeader)
    {
     List<Contact> Con = [SELECT Id, Email FROM Contact ];
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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;
               insert attachment;
               
               Messaging.SingleEmailMessage semail= new 
                Messaging.SingleEmailMessage();
               Messaging.EmailFileAttachment attach= new 
                   Messaging.EmailFileAttachment();
               attach.setBody(pref.getContentAsPDF());
               semail.setSubject('Quote Issued');
              String[] emailIds= new String[]{'abc@gmail.com'}; // I need this part has  
                 dynamic based on contact email id i choosed
               semail.setToAddresses(emailIds);
               
               semail.setPlainTextBody('Please find the attached quote details');
               semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
               Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
           }
    }
 
}


 
  • April 28, 2021
  • Like
  • 0
1.I am trying to come up with a Pdf Attachment in Email with the process builder.
2.In the Contact object, I have a Picklist field called Status__c values YES and No.
3.If Status__c is changed to Yes the email with pdf attachment to the particular contact.

 have Pdf coding, I need a PDF attachment in apex with process builder coding needed. Can help me out:(

PDF coding
 
<apex:page standardController="Account" renderAs="pdf">
 
Hey, the Account name is {!account.Name}
 
</apex:page>

 
  • April 28, 2021
  • Like
  • 0
My requirement  I have Contact Object with field Status__c(Picklist) Yes and No, if the Status__c changed to Yes then Pdf Attachment should send to the respective Contact with email automatically.

 I have already tried this link but does not work Not worked (https://www.linkedin.com/pulse/sending-email-attachment-using-process-builder-shweta-soparkar-/).

Can you all please share your thoughts and code for me
 
  • April 27, 2021
  • Like
  • 0
Getting error to open preview with Vfpage for Pdf Attachment in Email.

VFPage
 
<apex:page controller="cESend" >
<apex:pageBlock title="Send email example to the related conatct email of the Account:{!acc.Name}">
<p> This is the example of the vfpage</p>  
    <h1>Related Contacts for the Account:{!acc.Name}</h1>
 <apex:pageBlockTable value="{!acc.Contacts}" var="c">
        <apex:column headerValue="Name">{!c.Name}</apex:column>
        <apex:column headerValue="Email">{!c.Email}</apex:column>
    </apex:pageBlockTable> <br/><br/>
    <apex:form>
        <apex:outputLabel for="Subject" value="Subject">:<br/></apex:outputLabel>
            <apex:inputText size="80" maxlength="80" id="Subject" value="{!eSubject}" />:<br/><br/>
        <apex:outputLabel for="Body" value="Body">:<br/></apex:outputLabel>
        <apex:inputTextarea id="Body" cols="80" rows="8" value="{!eBody}"/><br/><br/>
        <apex:commandButton value="Send" action="{!SendEmail}" title="Send Email"/>
      </apex:form>
    </apex:pageBlock>    
  </apex:page>

Apex
public class cESend {
    public PageReference SendEmail(){
    Messaging.SingleEmailMessage email=new Messaging.SingleEmailMessage();
    pageReference pdfExample=Page.PDFGEN;
    pdfExample.setRedirect(true);
        
     Blob b=pdfExample.getContent();
        
    Messaging.EmailFileAttachment fa=new Messaging.EmailFileAttachment();
    fa.setFileName('AttachmentEmailFile.pdf');
        fa.setBody(b);
        
    String eAddress;
        if(acc.Contacts[0].email!=null){
            eAddress=acc.Contacts[0].email;
            for(Integer i=1;i<acc.Contacts.size();i++){
                
                if(acc.Contacts[i].email!=null){
                    eAddress =acc.Contacts[i].email;
                }
            }
            }
    string[] toAddress=eAddress.split(':',0);
    email.setSubject(eSubject);
    email.setPlainTextBody(eBody);
    email.setToAddresses(toAddress);
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {fa});
      //Now sending th email;
        Messaging.SendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        return null;
    }
    public Account acc{get;set;} 
    public string eSubject{get;set;} 
       public string eBody {get;set;} 
    
    
    public cEsend(){
    acc=[SELECT Name,(Select Name, Id,Email from Account.Contacts)from Account Where Id=:ApexPages.currentPage().getParameters().get('Id')];
        eSubject='';
        eBody='';
    }
                  }

Error

User-added image



 
  • April 27, 2021
  • Like
  • 0
public class cESend {
    
    public PageReference SendEmail(){
    Messaging.SingleEmailMessage email=new Messaging.SingleEmailMessage();
    pageReference pdfExample=Page.PDFGEN;
    pdfExample.setRedirect(true);
        
     Blob b=pdfExample.getContent();
        
    Messaging.EmailFileAttachment fa=new Messaging.EmailFileAttachment();
    fa.setFileName('AttachmentEmailFile.pdf');
        fa.setBody(b);
        
    String eAddress;
        if(acc.Contacts[0].email!=null){
            eAddress=acc.Contacts[0].email;
            for(Integer i=1;i<acc.Contacts.size();i++){
                
                if(acc.Contacts[i].email!=null){
                    eAddress =acc.Contacts[i].email;
                }
            }
            
            
        }
    string[] toAddress=eAddress.split(':',0);
    email.setSubject(eSubject);
    email.setPlainTextBody(eBody);
    email.setToAddresses(toAddress);
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {fa});
    
     
 
    //Now sending th email;
        Messaging.SendEmailResult[] r=Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
        return null;
    }
    public Account acc{get;set;} 
    public string eSubject{get;set;} 
       public string eBody {get;set;} 
    
    
    public cEsend(){
        
 acc=[SELECT Name(Select Name,(Select Name, Id,Email from Account.Contacts)from Account Where Id=:ApexPages.currentPage().getParameters().get('Id')];
        
        
        eSubject='';
        eBody='';
    }
 
    
    }
User-added imageThe error Curred in Select statement i don't know how fix it ,help plase
 
  • April 27, 2021
  • Like
  • 0
My requirement is I need send dynamic Pdf Attachment-based the Contact Name and Email, in Contact object I have a field called Status__c(picklist)values are new and signed when status__c is changed to new the email should send automatically to the user with email id with Pdf Attachment.IN process builder can we achieve?

Can you please help me out am new to salesforce? This code i have tried but unable to work... I need pfd with contact name,mail,and contact information on PDF ,when status__c changed to new automatic email should send with PDF Attachment, can you please help.i don't know how to set the condition and send pdf attachments in email

 
Vfpage

  <apex:page renderAs="PDF" > 

<h1 >Congratulations </h1 >
  This is your new Page 
 </apex:page>
 
public class SendVF_Email_InvocableMethod {
@InvocableMethod
public static void sendEmail(List<Id> lstId){
    List<String> EmailIds = 'ilovenagpur@gmail.com'.split(',');

    PageReference ref = Page.PDF_DEMO;
    Blob b = ref.getContentAsPDF();

    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

    Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
    efa1.setFileName('attachment_WORK.pdf');
    efa1.setBody(b);

    String addresses;
    email.setSubject( 'Check VF From PB' +String.valueOf(DateTime.now()));
    email.setToAddresses( EmailIds  );
    email.setPlainTextBody('Hey there, I am an email Body');
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}}

 
  • April 27, 2021
  • Like
  • 0
Unable to use Invocable annotation to pass two parameters to call in process builder.
 
public class poc {
    @InvocableMethod(label='Send Overall Quantum Details')
     public static void updateApplication(Id sourceId, string value){
        Loan_Application__c qa = new Loan_Application__c();
        qa.Id = sourceId;
        qa.Status__c = value;
        update qa;
    }
}



 
  • April 20, 2021
  • Like
  • 0
I have created the data table and the last trow should be empty the only the total should display but automatically it assuming like undefined. URL.
I need to set an empty value, any help

User-added image

 
getTransactionWithSummery(dataValues) {
            var totalAmount = 0.00;
            if (dataValues.length > 0) {
                for (var i = 0; i < dataValues.length; i++) {
                    totalAmount += dataValues[i].Amount__c;
                }
              
           dataValues.push({Amount__c: totalAmount.toFixed(2),GuarantorName:'Total'} );
            
           }
            return dataValues;
            
        }



any help ?
My requirement is I need to add the hyperlink in the pdf attachment in an email.
when they click the links in the email, there should navigate to the current record id. (For example, if I click that link in the email which  I received then that should navigate to contact record page with respective contact id)

It possible guys?
 
I Am stuck with an error I have created an apex with process bulder.
If I run the process it throws an error.

Error Occurred: common.apex.runtime.impl.ExecutionException: List has no rows for assignment to SObject
 
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
               
           } }
      
      private final Application__c account;
        public sendAnEmail() {
        account = [SELECT Id, Name  FROM Application__c 
                   WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
    }
        public Application__c getAccount() {
        return account;
    }

}

There is any resolved answer
 
  • April 30, 2021
  • Like
  • 0
I need to show the Contact name with Lookup with Application in pdf attachment..
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 FROM Application__c WHERE Id IN :listofQuoteHeader]);
           for(Id QuoteHeaderid :listofQuoteHeader)
           {
               PageReference pref= page.PDFGEN;
               pref.getParameters().put('id',(Id)QuoteHeaderid);
               pref.setRedirect(true);
               
               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});
           }
       
            }
  }

VF page
 
<apex:page standardController="Application__c" renderAs="pdf">
 <h1>
     Application__c.Contact__r.Name
    </h1>
</apex:page>

 
  • April 29, 2021
  • Like
  • 0
1.I am trying to come up with a Pdf Attachment in Email with the process builder.
2.In the Contact object, I have a Picklist field called Status__c values YES and No.
3.If Status__c is changed to Yes the email with pdf attachment to the particular contact.

 have Pdf coding, I need a PDF attachment in apex with process builder coding needed. Can help me out:(

PDF coding
 
<apex:page standardController="Account" renderAs="pdf">
 
Hey, the Account name is {!account.Name}
 
</apex:page>

 
  • April 28, 2021
  • Like
  • 0
My requirement is I need send dynamic Pdf Attachment-based the Contact Name and Email, in Contact object I have a field called Status__c(picklist)values are new and signed when status__c is changed to new the email should send automatically to the user with email id with Pdf Attachment.IN process builder can we achieve?

Can you please help me out am new to salesforce? This code i have tried but unable to work... I need pfd with contact name,mail,and contact information on PDF ,when status__c changed to new automatic email should send with PDF Attachment, can you please help.i don't know how to set the condition and send pdf attachments in email

 
Vfpage

  <apex:page renderAs="PDF" > 

<h1 >Congratulations </h1 >
  This is your new Page 
 </apex:page>
 
public class SendVF_Email_InvocableMethod {
@InvocableMethod
public static void sendEmail(List<Id> lstId){
    List<String> EmailIds = 'ilovenagpur@gmail.com'.split(',');

    PageReference ref = Page.PDF_DEMO;
    Blob b = ref.getContentAsPDF();

    Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();

    Messaging.EmailFileAttachment efa1 = new Messaging.EmailFileAttachment();
    efa1.setFileName('attachment_WORK.pdf');
    efa1.setBody(b);

    String addresses;
    email.setSubject( 'Check VF From PB' +String.valueOf(DateTime.now()));
    email.setToAddresses( EmailIds  );
    email.setPlainTextBody('Hey there, I am an email Body');
    email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa1});
    Messaging.SendEmailResult [] r = Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
}}

 
  • April 27, 2021
  • Like
  • 0
It is possible to create custom related to fields in lighting form or lwc possible.
I need like this in custom by using lwc or lighting record form?
User-added image
  • September 11, 2020
  • Like
  • 0
IController Transloan=new LoanController();
       Loan__c tloan=new Loan__c();
       sObj=(Loan_Transaction__c)obj;
       tobj.Related_Object_Name__c='Loan_Transaction__c';
      tloan=(Loan__c)Transloan.getById();
        if(tloan.Account__c!=null){
            tobj.Object_Id__c=tloan.Account__c;
            }
            else{
                 tobj.Object_Id__c=tloan.Contact__c;
            }
        
  • September 01, 2020
  • Like
  • 0
I have picklist field name is Type__c and in that values are Disbursal and payment, where Disbursal=1000 & Payment is =5000.
My requirement is when I choose disbursal I need a trigger and show the values of disbursal of 1000 and the same as payment need to show if I chose a payment.
This code of trigger.
trigger TransactionAct on Loan_Transaction__c (after insert) {
    List<Timeline_Event__c> timelineList=new List<Timeline_Event__c>();
    TimelineEventController tobj=new TimelineEventController();
    ITimelineEventController timeAssignCtrl=new TimelineEventController();
    IController conCtrl=new contactController();
    
  	for( Loan_Transaction__c trans :Trigger.New){
        Timeline_Event__c tEvent=new Timeline_Event__c();
               string rtype='', subtitle='';
        
        if( Trigger.isAfter){
                sObject c=conCtrl.getById(trans.Loan__c);

            if(trans.Type__c=='Disbursal'){
                subtitle=rtype+'Disbursal of';
  tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans ,'trans Disbural',subtitle,'insert','trans' );
         timelineList.add(tEvent);
            }    
            else if(trans.Type__c=='Payment'){
                 subtitle=rtype+'Payment of';
                 tEvent=(Timeline_Event__c)timeAssignCtrl.timelineTrigger(trans,'trans Payment','',subtitle,'insert','tarns'  );
                 timelineList.add(tEvent);
            }
            
            
        }
 
          }
   tobj.createMany(timelineList);  

}

 
  • August 25, 2020
  • Like
  • 0
My requirement is when i click the refresh button it should display the date and time like standard report chart.there is any solution 

i need like this
User-added image
This is my code:
Html 
      <button class="slds-input__icon slds-button slds-button_icon iconheight" onclick={today}>
 
js

      
var today = new Date();

console.log("hi");

var date =  String(today.getFullYear()+'-'+(today.getMonth()+1)+'-'+today.getDate());

var time = String(today.getHours() + ":" + today.getMinutes() + ":" + today.getSeconds());

var dateTime = date+' '+time;

    
today(){
        this.expenseAmount();
    }
this.expenseAmount is having full data

 
I have Loan object with three fields and look up relation with application in application object also i has same three fields ,now i need to fetch the data from apex class

 This my apex code:
public static List <SObject> chart(Id id){
    List<sObject> entities= [SELECT Total_Jobs_Created__c,Total_Jobs_Lost__c,Total_Jobs_Maintained__c, Application__r.Total_Jobs_Created__c,Application__r.Total_Jobs_Lost__c,Application__r.Total_Jobs_Maintained__c
  FROM Loan__c  WHERE Id=:id];

   return entities;
}

This my js code:
loanImpactjobs() {
          console.log("sai")
        this.loading=true;
        let loanjobs={'sobjectType':'Loan__c'};
        chart({id:this.recordId }).then(data=>{
        if(data!==''&& data!== 'null' && data!=='undefined'){  
            var jobs=JSON.parse(this.details);
            this.LCreatedjobsValue=jobs["Total_Jobs_Created__c"];
            console.log(this.LMaintainedjobsValue)
            this.LLostjobsValue=jobs["Total_Jobs_Lost__c"];
            console.log(this.LCreatedjobsValue);
            this.LMaintainedjobsValue=jobs["Total_Jobs_Maintained__c"];
            console.log(this.LLostjobsValue);
           
        }
        } ).catch(error => {
            this.errorMessage(error);
        });
    }

i used this code only ,but it doesnt worked anything ineed to chnage?
This my code i used(anything i need to modify,please let me know).
import { LightningElement, track, api,wire } from 'lwc';
import { getRecord,getFieldValue  } from 'lightning/uiRecordApi';
@track recType; 
@api recordId;
@track LjobsValue;
@track CjobsValue;
@track MjobsValue;
@wire(getRecord, { recordId: '$recordId', layoutTypes: ['Full'], modes: ['View'] })
    wiredRecord({data,error}) {
       if (data) { 
       var result = JSON.parse(JSON.stringify(data)); 
       this.recType=result.recordTypeId;
       this.LjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Lost__c');
       this.MjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Maintained__c');
       this.CjobsValue=getFieldValue(data,'Loan__c.Total_Jobs_Created__c');
       }
       else{
         this.error=error;  
         console.log(error);
       }
   }
i used this code it throws error in console

this cause error:User-added image