• Neeraj Sharma 103
  • NEWBIE
  • 265 Points
  • Member since 2019

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 33
    Questions
  • 34
    Replies
Hi Everyone 

How to create gantt chart in aura component any have created in aura component any idea how to achieve this functionality  below is the screen i wanna to create in aura component 
User-added image
How to use external Service functionality for callout in salesforce with Process Builder
Hi Everyone I have three Custom Objects 
CustomObj A
Custom Obj B
Custom Obj C

CustomObj A is the lookup on Custom Obj B and Custom Obj C 
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C  I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
Hi Everyone Anyone Help Me I want to use After Insert,After Update,After Delete in one trigger  througth  trigger Handler and 
i want to call all these events in one method from trigger in trigger handler class  

Anyone Have Example anyone do this types of scenarios when used these events so please help me
Hi

Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them

Attendance__c lookup (Contact)

Thanks and Regards 
neeraj Sharma
Hi 
I Have Created a Custom VF Page for Registration Community User

But When  my domain url search on another browser then  custom login page is open but when i click on register then its shows below error from site  
User-added image




My Domain URL IS :

https://pmportal-developer-edition.ap15.force.com/PMPortal


Thanks & Regards
Neeraj Sharma
Hi 
I Have Created a Custom VF Page for Registration Community User

But When  my domai n url search on another browser then  custom login page is open but when i click on register then its shows below error from site  User-added imageMy Domain URL IS :

https://pmportal-developer-edition.ap15.force.com/PMPortal


Thanks & Regards
Neeraj Sharma
Hi Everyone

Anyone Create Custom VF page for Registration of Community User and Controller Class Anyone Do So Please Share With me 

Thanks 
Neeraj Sharma
Hi Everyone Please Help me 

How to Create Registration Visual force Page for community user anyone create so please help me any example 
Trigger

trigger LeadTrigger on Lead(before insert, before Update) {

    if (trigger.isInsert && trigger.isBefore) {
        LeadTriggerHandler.onBeforeInsert(trigger.new);

    } else if (trigger.isUpdate && trigger.isBefore) {
        LeadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap);
    }
}
 
TrigerHandlerClass

public class LeadTriggerHandler {
  
    public static String STATUS_SELF_REPRESENTED = 'Self Represented';
    
  
    public static void onBeforeInsert(list <Lead> newLeadList){
        updateFldsOnLead(newLeadList, null);
    }

   
    public static void onBeforeUpdate(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        updateFldsOnLead(newLeadList, oldLeadMap);
    }

    public static void updateFldsOnLead(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        map<String, list<lead>> zipCodeLeadMap = new Map <String, list<lead>> ();

       for(Lead ld: newLeadList){
            if(ld.Status != STATUS_SELF_REPRESENTED && ld.PostalCode != null){
              
               
                if(!zipCodeLeadMap.containsKey(ld.PostalCode)){
                    zipCodeLeadMap.put(ld.PostalCode, new list<lead>());
                }
                zipCodeLeadMap.get(ld.PostalCode).add(ld);
            }

        }
        if(zipCodeLeadMap.size() > 0){
           
            for(Lead_WF_Configuration__mdt ldConfigCMD: [Select Id, Zip_Postal__c, State__c, County__c,OwnerID__c
                                                          From Lead_WF_Configuration__mdt]){
                                                
                for(String zip: zipCodeLeadMap.keySet()){
                    
                    if(String.valueOf(ldConfigCMD.Zip_Postal__c).contains(zip)){
                        
                        
                        for(Lead ld: zipCodeLeadMap.get(zip)){
                            ld.State = ldConfigCMD.State__c;
                            ld.County__c = ldConfigCMD.County__c;
                            ld.OwnerId = ldConfigCMD.OwnerID__c;
                        }
                 }
                 }
            }
        }
    }
}

 
Hi Experts

Hi Everyone When i used Bootstrap 4 in visualforce page then the tag color will be different how its is possbile and developer console is not showing any errorUser-added image
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button when user fill the form and then clicked on save button then the data will be stored as a pdf and download it 
So Any Example how to achieve this functionaliy 
Hi Please help for test class

public with sharing class schedulexpensecontroller {

     public list<Expense_Management__c> con{get;set;}  
     public list<Expense_Management__c> em{get;set;}  
     public double total1{get;set;} 
     public Date fromdate{get;set;}
     public Date todate{get;set;}
     
	 public Id parent {get;set;} 
    
     public schedulexpensecontroller(){
    	
        
  	    Id conId = apexpages.currentpage().getparameters().get('id');
        parent = UserInfo.getUserId();
         
 			
                     
          
        if(apexpages.currentpage().getparameters().get('fromdate') !=null && apexpages.currentpage().getparameters().get('todate')!=null)
        {
             fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate'));
             todate = Date.Parse(apexpages.currentpage().getparameters().get('todate'));
            
            con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c,
                  Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c	,
                  Lodging_Expense__c,Miscellaneous_Expense__c,
                  Description__c,Total_Expenses__c,Local_Conveyance__c,	Paid_Amount__c,Payment__c,
                  Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c
                  where Name_of_Employee__c =: parent AND CreatedDate >=: fromdate AND CreatedDate <=: todate];
            
            em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: parent];  
        }else
        {
            
              con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c,
                  Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c	,
                  Lodging_Expense__c,Miscellaneous_Expense__c,
                  Description__c,Total_Expenses__c,Local_Conveyance__c,	Paid_Amount__c,Payment__c,
                  Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c
                  where Name_of_Employee__c =: conId ];
            
              em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: conId];
        }
        
    }
}
@isTest
public class Testclassforscheduleexpensecontroller {

    @isTest static void testmethod1()
    {
        schedulexpensecontroller cons= new schedulexpensecontroller();
          // Date from1;
      // cons.fromdate=from1.parse('06/18/2019');
        
       
       //fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate'));
    }
}


 
public class EmailInvoiceA {
    
    @auraEnabled
    public static void sendMailWithPDF(String recordId){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           sendTo.add(cc.Distributor__r.E_mail__c);
            
            List<String> send = new List<String>();
            if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
            {  
                send.add(cc.Distributor__r.CC_to_if_any__c);
               semail.setToAddresses(send);
            }
            else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
            {
                sendTo.add(cc.Distributor__r.E_mail__c);
                send.add(cc.Distributor__r.CC_to_if_any__c);
              semail.setccAddresses(send);
              semail.setToAddresses(sendTo);
                
           }
           else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
            {  
              sendTo.add(cc.Distributor__r.E_mail__c);
                   semail.setToAddresses(sendTo);
         }
                mails.add(semail);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }      
    @auraEnabled
     public static void sendMailWith(String recordId,String mMail){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            sendTo.add(mMail);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
           
              List<String> send = new List<String>();
            if(cc.Distributor__r.CC_to_if_any__c != null)
            {
                 send.add(cc.Distributor__r.CC_to_if_any__c);
                 
            }
            mails.add(semail);
			semail.setCcAddresses(send);
            semail.setToAddresses(sendTo);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }    
     @auraEnabled
   public static void Mail(String recordId,String mMail,boolean checkCmp){
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
  
           if(checkCmp==true)
               {
                  sendTo.add(mMail);
                   semail.setToAddresses(sendTo);
               }
           else  if(checkCmp==false)
            {
              if(mMail != null)
            {
                sendTo.add(mMail);
            	semail.setToAddresses(sendTo);
            }   
             if(cc.Distributor__r.E_mail__c != null)
            {
               sendTo.add(cc.Distributor__r.E_mail__c);  
                semail.setToAddresses(sendTo);
            } 
                
             if(cc.Distributor__r.CC_to_if_any__c != null)
            { 
                List<String> send = new List<String>();//cc string
				send.add(cc.Distributor__r.CC_to_if_any__c);  
               semail.setCcAddresses(send);
           }   
            }
            mails.add(semail);

            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }       
}

 
Hi Experts 

Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component  I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example 


Thanks in Advance
Neeraj Sharma
Hi Experts Please Help me For Below Code

in this code i used lightning data table it show not proper in salesforce1 mobile app its shows like this:User-added image
<aura:component implements="force:LightningQuickAction,force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="Eventrecordcomponent">
  
    <!-- attributes -->
    <aura:attribute name="recordId" type="String"></aura:attribute>
     <aura:attribute name="recordTypes" type="String"></aura:attribute>
    <aura:attribute name="mydata" type="Object"></aura:attribute>
    <aura:attribute name="mycolumns" type="List"></aura:attribute>
    <aura:attribute name="noResults" type="String"></aura:attribute>
   
    <!-- handlers-->
    <aura:handler name="init" value="{!this }" action="{!c.init }"></aura:handler>
   <article aura:id="gridContainer" class="slds-card slds-card_boundary">
        <lightning:card title="Check In/Check Out Manager" iconName="standard:document">
            <div class="slds-card__header slds-grid">
                <aura:if isTrue="{!not(empty(v.mydata))}" >
                    <!-- the container element determine the height of the datatable -->
                    <lightning:datatable keyField="id"
                            data="{! v.mydata }"
                            columns="{! v.mycolumns }"
                            hideCheckboxColumn="true"
                         
                         ></lightning:datatable>
                </aura:if>
                <aura:if isTrue="{!empty(v.mydata)}" >
                    <p Style="color:red;">{! v.noResults }</p>
                  
                </aura:if>
            </div>
        </lightning:card>
    </article>
</aura:component>

So Please Replay ASAP 
Thanks in Advance
Neeraj
Hi  
Everyone How to calculate distance between two marker and show them on the Map like CheckIn and CheckOut when user check in then its show on the map i doing this already now i want to show checkout also on the map and also distance calculate between them and  distance show on the checkin marker 

Please Replay ASAP 
Thanks in Advance
Neeraj
Please Help me to write test class for below apex class controller


abc.apexclass


public class EmailInvoiceA {
    
    @auraEnabled
    public static void sendMailWithPDF(String recordId){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
           sendTo.add(cc.Distributor__r.E_mail__c);
            
            List<String> send = new List<String>();//cc string
            system.debug('sendlis'+send);
        //    if(cc.Distributor__r.CC_to_if_any__c != null)
      //      {
        //         send.add(cc.Distributor__r.CC_to_if_any__c);
                 
     //       }
            
            if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
            {  
                
                send.add(cc.Distributor__r.CC_to_if_any__c);
               //semail.setccAddresses(sendTo);
               semail.setToAddresses(send);
           
            }
            else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
            {
                sendTo.add(cc.Distributor__r.E_mail__c);
                send.add(cc.Distributor__r.CC_to_if_any__c);
                
              semail.setccAddresses(send);
              semail.setToAddresses(sendTo);
                
           }
           else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
            {
                
              sendTo.add(cc.Distributor__r.E_mail__c);
               
                   semail.setToAddresses(sendTo);
         }
       
        
                mails.add(semail);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }    
  
    
    @auraEnabled
     public static void sendMailWith(String recordId,String mMail){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            sendTo.add(mMail);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
            //sendTo.add(cc.Distributor__r.E_mail__c);
              List<String> send = new List<String>();
            if(cc.Distributor__r.CC_to_if_any__c != null)
            {
                 send.add(cc.Distributor__r.CC_to_if_any__c);
                 
            }
         
            mails.add(semail);
            semail.setCcAddresses(send);
            semail.setToAddresses(sendTo);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }    
  
    
     @auraEnabled
   public static void Mail(String recordId,String mMail,boolean checkCmp){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
           
              system.debug(checkCmp);  
           
       //     semail.setToAddresses(sendTo);
          //shrutinigam1998@gmail.com  
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            
            
            
           if(checkCmp==true)
               {
                  sendTo.add(mMail);
                   semail.setToAddresses(sendTo);
               }
           else  if(checkCmp==false)
            {
               system.debug('hi check'+checkCmp);
              if(mMail != null)
            {
                 system.debug('hi mMail'+mMail);
                sendTo.add(mMail);
                semail.setToAddresses(sendTo);
            }
                
             if(cc.Distributor__r.E_mail__c != null)
            { system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
               sendTo.add(cc.Distributor__r.E_mail__c);  
                semail.setToAddresses(sendTo);
            } 
                
             if(cc.Distributor__r.CC_to_if_any__c != null)
   
            { 
                system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
                List<String> send = new List<String>();//cc string
                send.add(cc.Distributor__r.CC_to_if_any__c);  
               semail.setCcAddresses(send);
           }   
                
                
                
            }
            
      
            mails.add(semail);

            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }       
}
HI all,
I habve created a quick lightning action button and in the pop up i have placed one checkbox.

Problrm is that when condition is false it is working perfectly when it is true it is not calling the aura enabled class in controller.

 
Hi 

I am new in Salesforce Begineer

My Question is:

How to validate Phone field of Account Object with Use of Apex Class and the validation is ONly 10 Digit is input by user no sepcial character no characters Only digits and digit will be 10 
and if user input digit according the condition then the record will be save and user not input 10digit then error will be show on the Phone field "Please Provide Valid Number"  on Custom Visual force Page
Please help me ASAP


Thanks 
Neeraj Sharma
 
How to use external Service functionality for callout in salesforce with Process Builder
Hi Everyone I have three Custom Objects 
CustomObj A
Custom Obj B
Custom Obj C

CustomObj A is the lookup on Custom Obj B and Custom Obj C 
But Custom Obj B and Custom Obj C in between there is no relation between us Now My Requirement is there is a Number fields on Custom Obj B and Custom Obj C  I want to SumUp of both these fields and Populate on CustomObj A So How to achieve this requirement Please tell me
Hi

Everyone How to insert a record in custom object which is under in Contact Standard Object Lookup RelationShip Between them

Attendance__c lookup (Contact)

Thanks and Regards 
neeraj Sharma
Trigger

trigger LeadTrigger on Lead(before insert, before Update) {

    if (trigger.isInsert && trigger.isBefore) {
        LeadTriggerHandler.onBeforeInsert(trigger.new);

    } else if (trigger.isUpdate && trigger.isBefore) {
        LeadTriggerHandler.onBeforeUpdate(trigger.new, trigger.oldMap);
    }
}
 
TrigerHandlerClass

public class LeadTriggerHandler {
  
    public static String STATUS_SELF_REPRESENTED = 'Self Represented';
    
  
    public static void onBeforeInsert(list <Lead> newLeadList){
        updateFldsOnLead(newLeadList, null);
    }

   
    public static void onBeforeUpdate(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        updateFldsOnLead(newLeadList, oldLeadMap);
    }

    public static void updateFldsOnLead(list <Lead> newLeadList, map <Id, Lead> oldLeadMap){
        map<String, list<lead>> zipCodeLeadMap = new Map <String, list<lead>> ();

       for(Lead ld: newLeadList){
            if(ld.Status != STATUS_SELF_REPRESENTED && ld.PostalCode != null){
              
               
                if(!zipCodeLeadMap.containsKey(ld.PostalCode)){
                    zipCodeLeadMap.put(ld.PostalCode, new list<lead>());
                }
                zipCodeLeadMap.get(ld.PostalCode).add(ld);
            }

        }
        if(zipCodeLeadMap.size() > 0){
           
            for(Lead_WF_Configuration__mdt ldConfigCMD: [Select Id, Zip_Postal__c, State__c, County__c,OwnerID__c
                                                          From Lead_WF_Configuration__mdt]){
                                                
                for(String zip: zipCodeLeadMap.keySet()){
                    
                    if(String.valueOf(ldConfigCMD.Zip_Postal__c).contains(zip)){
                        
                        
                        for(Lead ld: zipCodeLeadMap.get(zip)){
                            ld.State = ldConfigCMD.State__c;
                            ld.County__c = ldConfigCMD.County__c;
                            ld.OwnerId = ldConfigCMD.OwnerID__c;
                        }
                 }
                 }
            }
        }
    }
}

 
Hi Experts i have a Simple vf page and in vf page some fields are input and a save button when user fill the form and then clicked on save button then the data will be stored as a pdf and download it 
So Any Example how to achieve this functionaliy 
Hi Please help for test class

public with sharing class schedulexpensecontroller {

     public list<Expense_Management__c> con{get;set;}  
     public list<Expense_Management__c> em{get;set;}  
     public double total1{get;set;} 
     public Date fromdate{get;set;}
     public Date todate{get;set;}
     
	 public Id parent {get;set;} 
    
     public schedulexpensecontroller(){
    	
        
  	    Id conId = apexpages.currentpage().getparameters().get('id');
        parent = UserInfo.getUserId();
         
 			
                     
          
        if(apexpages.currentpage().getparameters().get('fromdate') !=null && apexpages.currentpage().getparameters().get('todate')!=null)
        {
             fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate'));
             todate = Date.Parse(apexpages.currentpage().getparameters().get('todate'));
            
            con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c,
                  Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c	,
                  Lodging_Expense__c,Miscellaneous_Expense__c,
                  Description__c,Total_Expenses__c,Local_Conveyance__c,	Paid_Amount__c,Payment__c,
                  Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c
                  where Name_of_Employee__c =: parent AND CreatedDate >=: fromdate AND CreatedDate <=: todate];
            
            em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: parent];  
        }else
        {
            
              con = [Select Date__c,From__c,To__c,Purpose_of_Travel__c,Mode_of_Travel__c,
                  Opening_KM__c,Closing_KM__c,Rate__c,Total_Km__c,Total_Travel_Expense__c	,
                  Lodging_Expense__c,Miscellaneous_Expense__c,
                  Description__c,Total_Expenses__c,Local_Conveyance__c,	Paid_Amount__c,Payment__c,
                  Name_of_Employee__r.EmployeeNumber,Name_of_Employee__r.UserRole.Name,Name_of_Employee__r.Name from Expense_Management__c
                  where Name_of_Employee__c =: conId ];
            
              em = [Select Payment__c,Total_Expenses__c from Expense_Management__c where Payment__c = 'unpaid' AND Name_of_Employee__c =: conId];
        }
        
    }
}
@isTest
public class Testclassforscheduleexpensecontroller {

    @isTest static void testmethod1()
    {
        schedulexpensecontroller cons= new schedulexpensecontroller();
          // Date from1;
      // cons.fromdate=from1.parse('06/18/2019');
        
       
       //fromdate = Date.Parse(apexpages.currentpage().getparameters().get('fromdate'));
    }
}


 
Hi Experts 

Can we create a salesforce bell notification for approval process using Apex Trigger,Apex class , Lightning Component  I searched on google also its says By Using Process builder we create a salesforce custom notification but i want to send notification when user clicked on the submit for approval button i am and in approval process My Users in queues so salesforce not sent bell notification to Queue Users so how to send bell notificatio Queue Users If any one doing this type of scenario so please share with me Any Example 


Thanks in Advance
Neeraj Sharma
Please Help me to write test class for below apex class controller


abc.apexclass


public class EmailInvoiceA {
    
    @auraEnabled
    public static void sendMailWithPDF(String recordId){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
           sendTo.add(cc.Distributor__r.E_mail__c);
            
            List<String> send = new List<String>();//cc string
            system.debug('sendlis'+send);
        //    if(cc.Distributor__r.CC_to_if_any__c != null)
      //      {
        //         send.add(cc.Distributor__r.CC_to_if_any__c);
                 
     //       }
            
            if(cc.Distributor__r.E_mail__c==null && cc.Distributor__r.CC_to_if_any__c != null)
            {  
                
                send.add(cc.Distributor__r.CC_to_if_any__c);
               //semail.setccAddresses(sendTo);
               semail.setToAddresses(send);
           
            }
            else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c != null)
            {
                sendTo.add(cc.Distributor__r.E_mail__c);
                send.add(cc.Distributor__r.CC_to_if_any__c);
                
              semail.setccAddresses(send);
              semail.setToAddresses(sendTo);
                
           }
           else if(cc.Distributor__r.E_mail__c !=null && cc.Distributor__r.CC_to_if_any__c == null)
            {
                
              sendTo.add(cc.Distributor__r.E_mail__c);
               
                   semail.setToAddresses(sendTo);
         }
       
        
                mails.add(semail);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
        }
    }    
  
    
    @auraEnabled
     public static void sendMailWith(String recordId,String mMail){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();
            sendTo.add(mMail);
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
           
            //sendTo.add(cc.Distributor__r.E_mail__c);
              List<String> send = new List<String>();
            if(cc.Distributor__r.CC_to_if_any__c != null)
            {
                 send.add(cc.Distributor__r.CC_to_if_any__c);
                 
            }
         
            mails.add(semail);
            semail.setCcAddresses(send);
            semail.setToAddresses(sendTo);
            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }    
  
    
     @auraEnabled
   public static void Mail(String recordId,String mMail,boolean checkCmp){
        
        for(Invoice__c cc : [select Id,Distributor__r.E_mail__c,Distributor__r.CC_to_if_any__c,Distributor__r.Name from Invoice__c WHERE Id =: recordId]){
            list<Messaging.SingleEmailMessage> mails =  new List<Messaging.SingleEmailMessage>();  
            Messaging.SingleEmailMessage semail = new Messaging.SingleEmailMessage();
            List<String> sendTo = new List<String>();//to string
           
              system.debug(checkCmp);  
           
       //     semail.setToAddresses(sendTo);
          //shrutinigam1998@gmail.com  
        
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            PageReference pref = page.PdfEmailInvoice;
            pref.getParameters().put('Id',recordId);
            pref.setRedirect(true);
            Blob b;
            b = pref.getContent();
            attach.setFileName('Invoice.pdf');
            attach.setBody(b);
            semail.setSubject('Invoice details');
            semail.setReplyTo('noreply@gmail.com');
            semail.setSenderDisplayName('salesforce User');
            
            
            
           if(checkCmp==true)
               {
                  sendTo.add(mMail);
                   semail.setToAddresses(sendTo);
               }
           else  if(checkCmp==false)
            {
               system.debug('hi check'+checkCmp);
              if(mMail != null)
            {
                 system.debug('hi mMail'+mMail);
                sendTo.add(mMail);
                semail.setToAddresses(sendTo);
            }
                
             if(cc.Distributor__r.E_mail__c != null)
            { system.debug('hi Distributor mail'+cc.Distributor__r.E_mail__c);
               sendTo.add(cc.Distributor__r.E_mail__c);  
                semail.setToAddresses(sendTo);
            } 
                
             if(cc.Distributor__r.CC_to_if_any__c != null)
   
            { 
                system.debug('hi Distributor cc mail'+cc.Distributor__r.CC_to_if_any__c);
                List<String> send = new List<String>();//cc string
                send.add(cc.Distributor__r.CC_to_if_any__c);  
               semail.setCcAddresses(send);
           }   
                
                
                
            }
            
      
            mails.add(semail);

            String emailBody =' <html><body><p> Dear '+ cc.Distributor__r.Name+' ,<br><br> Please find the attached Invoice details. <br><br>    Regards, <br> IT Team <br>  Sayaji Groups.</p></body></html>';
            semail.setHtmlBody(emailBody);
            semail.setFileAttachments(new Messaging.EmailFileAttachment[]{attach});
            Messaging.sendEmail(new Messaging.SingleEmailMessage[]{semail});
            system.debug('email send');
        }
    }       
}
Hi Everyone this is my trigger i want to write test class for this so please help me i tried but not accomplish my requirement code coverge approx 75%



trigger Distributor on Account (before insert) {
    
String role;   
String owner;
    
  list<Account> changeOwner=new list<Account>();
    
    for(Account acc:trigger.new){
        
       if(acc.Under__c=='Chhattisgarh'){
           role=' CG';
          changeOwner.add(acc);
       }
      
       else if(acc.Under__c=='Bihar'){
           role=' BI';
         changeOwner.add(acc);
       }  
        
      else if(acc.Under__c=='Rajasthan') {
           role=' RJ';
           changeOwner.add(acc);
           }  
      else if(acc.Under__c=='Gujarat'){
           role=' GJ';
          changeOwner.add(acc);
           }
        
      else if(acc.Under__c=='Haryana'){
           role=' HR';
         changeOwner.add(acc);
           
       }
        
      else if(acc.Under__c=='Jharkhand'){
           role=' JH';
         changeOwner.add(acc);
       } 
        
      else if(acc.Under__c=='Maharashtra'){
           role=' MH';
         changeOwner.add(acc);
       }
        
       else if(acc.Under__c=='Madhya Pradesh'){
           role=' MP';
         changeOwner.add(acc);
       }  
       else if(acc.Under__c=='Uttar Pradesh'){
           role=' UP';
        changeOwner.add(acc);
       } 
        
   }
    String SOSTR = String.valueOf('SO') + String.valueOf(role);  
    String ASMSTR = String.valueOf('ASM') + String.valueOf(role);
    String DRMSTR = String.valueOf('DRM') + String.valueOf(role);
    String RMSTR = String.valueOf('RM') + String.valueOf(role);


  list <User> socg1=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :SOSTR Order By FirstName,LastName');
  list <User> socg2=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :ASMSTR Order By FirstName,LastName');
  list <User> socg3=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :DRMSTR  Order By FirstName,LastName');
  list <User> socg4=Database.query('SELECT Id,Name FROM User WHERE UserRole.Name = :RMSTR Order By FirstName,LastName');
  
   if(socg1.size()>0){
        owner=socg1.get(0).id;
    }
    
     else if(socg1.size()<=0){
     
        if(socg2.size()>0){
            owner=socg2.get(0).id; 
        }
        
        else if(socg2.size()<=0){
            
            if(socg3.size()>0){
              owner=socg2.get(0).id;  
             }
        
        else if(socg3.size()<=0){
            
             if(socg4.size()>0) {
               owner=socg4.get(0).id;   
             }   
        }
      }
   }
    
   for(Account acc:changeOwner){
       
        if(socg1!=null){
            acc.OwnerId=Owner;
        }
           
    }
   
}

Hi Everyone Please help me out from this scenario

 I want to update Account record owner incase custom state field is anyone selected from picklist(Gujarat,Rajasthan,Bihar,etc) with higher role and role checked 

User-added image
four levels above in role hiearchy if state chandigarh is select then (SOCG (SalesOfficer Chandigarh)) in this role the user will be updated on record owner and if no user in role of (SOCG) then above him(ASM CG) user is update on record owner this level go up to last level at (RM CG) 
and if RMCG in this role there is no user then by default  record owner will be update to this role user(RM CG)