function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nilesh walkenilesh walke 

i want to Add a custom button on Account and add make a page that can view related contatcto it can someone help me my question is below one i am new to this don't know how it works

1, Create a button on account to show only contact related to selected account. On button click open VF page
, Facility to select the multiple contact from list
,add Send email button on Table so user will send an Email to selected Contacts
,Pagination should be present for Table
 
mukesh guptamukesh gupta
Hi Nilesh,

You can use quickaction that will navigate to custom lightning component. this quick action you can add on Account page

if you need any assistanse, Please let me know!!


Kindly mark my solution as the best answer if it helps you.

Thanks
Mukesh
nilesh walkenilesh walke
hii Mukesh  thanks for replying actully  i want the code that how i can get related contact to a associated account in a vf page
 and i want to  send mail to  only the selected contacts
nilesh walkenilesh walke
i already created a custom button on the account details page when i click on the button it should show me the contact related to the account and  and that list should have  multiple selection box that i can select a contact and send the mail at once  to all the  contacts
SwethaSwetha (Salesforce Developers) 
HI Nilesh,
The code in https://salesforce.stackexchange.com/questions/33930/want-to-display-contacts-table-when-i-click-on-one-account should help you get started

If this information helps, please mark the answer as best. Thank you
nilesh walkenilesh walke
hi Swetha 
 i have this class and page i want to do it using jquery can you help me out

public class test4 {
    List<contactwrapper> contactList = new List<contactwrapper>();
    private String recordId; 
    public List<ContactWrapper> wconlist;
    List<contact> selectedContacts = new List<contact>();
    List<contact> selectedContacts1 = new List<contact>();
    public class contactWrapper{
        public contact con { get; set; }
        public Boolean isRendered { get; set; }
        public boolean isSelected {get; set;}
    }
    public test4(){
            recordId = ApexPages.currentPage().getParameters().get('id');
        }  
    public List<contactWrapper> getcontactWrappers() {
        List<contactWrapper> contactWrappersToReturn = new List<contactWrapper>();
        List<Contact> conlist = [SELECT ID, Name,phone,Email from Contact WHERE AccountId=:recordId]; 
        for (Contact conn : conlist ) {
            // create a wrapper to allow you to indicate visibility
            ContactWrapper conWrapper = new ContactWrapper();
            // stick the Account into the wrapper
            conWrapper.con = conn ;          
            contactList.add(conWrapper);
        }   
        return contactList;   
    }      
    public List<contact> GetSelectedcontacts()
    {
        if(selectedcontacts1.size()>0)
            return selectedcontacts1;       
        else
            return null;
    }    
    public void SendMail(){ 
        system.debug('sendmail'+selectedContacts1);
        String [] toAddresses = new List<String>();    
        for(Contact con : selectedContacts1) {
            toAddresses.add(con.Email);           
        }
        System.debug('toaddresses==>'+toAddresses);
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setSubject('Account related contacts' );
        mail.setHtmlBody('thanks for contacts');
        Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });   
        
    }  
}


page using jQuery
<apex:page controller="test4" showHeader="false" standardStylesheets="false">
    <apex:form > 
        <apex:pageBlock > 
            <apex:pageBlockButtons location="bottom" >
                <apex:CommandButton value="Send Email" action="{!SendMail}" reRender="table" />
            </apex:pageBlockButtons>    
            <apex:stylesheet value="//cdn.datatables.net/1.10.5/css/jquery.dataTables.css"/>
            <apex:includeScript value="//code.jquery.com/jquery-1.10.2.min.js"/>
            <apex:includeScript value="//cdn.datatables.net/1.10.5/js/jquery.dataTables.js"/>
            <div style="width:80%; margin-left:auto; margin-right:auto; margin-top:50px;">
                <table id="table_id" class="display">
                    <thead>
                        <tr>
                            <th><input type="checkbox" class="selectAll" checked=""/></th>
                            <th>Contact Name</th>
                            <th>phone</th>
                            <th>Email</th>
                        </tr>
                    </thead>
                    <tbody>
                        <apex:repeat value="{!ContactWrappers}" var="conlist">
                            <tr>
                                <td><input type="checkbox" id="chk{!conlist.isRendered}" name="chk{!conlist.con.id}"/></td>
                                <td>{!conlist.con.name}</td>
                                <td>{!conlist.con.phone}</td>
                                <td>{!conlist.con.Email}</td>
                            </tr>
                        </apex:repeat>               
                    </tbody>
                </table>
            </div>
            <script>
            $(document).ready( function () {
                $('#table_id').DataTable();
                $('#chktrue').attr('disabled','true');
            } );            
            (function($) {               
                'use strict';               
                $.fn.extend({
                    checkboxes: function(options) {
                        // Default option
                        var defaults = {
                            itemChild: ''
                        };                        
                        var option = $.extend(defaults, options);
                                                // Checked value function
                        function checkedValue(element, bool) {
                            if (bool) {
                                return element.each(function() {
                                    $(this).prop('checked', true);
                                });
                            } else {
                                return element.each(function() {
                                    $(this).prop('checked', false);
                                });
                            }
                            $(":checkbox").click(function(){
                                $("#id").text(this.value)
                            })                            
                        }                        
                        // Return checked or unchecked
                        return this.each(function() {
                            var obj = option,
                                $itemAll = $(this),
                                $itemChild = $('input[name^="' + obj.itemChild + '"]');
                                                        // Checked all checkbox before parent checked load page
                            if ($itemAll.is(':checked')) {
                                checkedValue($itemChild, true);
                            }
                      // Checked all or unchecked checkbox when parent checkbox checked or unchecked
                            $itemAll.change(function() {
                                var $self = $(this);
                                
                                if ($self.is(':checked')) {
                                    checkedValue($itemChild, true);
                                } else {
                                    checkedValue($itemChild, false);
                                }
                            });
                   // Checked parent checkbox when all child checkbox checked
                            $itemChild.change(function() {
                                var flag = true;
                                
                                if (!$itemChild.is(':checked')) {
                                    console.log(!$itemChild.is(':checked'));
                                    $itemAll.prop('checked', false);
                                }
                                
                                $itemChild.each(function() {
                                    var $self = $(this);
                                    if (!$self.is(':checked')) {
                                        flag = false;
                                        return;
                                    }
                                });                               
                                $itemAll.prop('checked', flag);
                            });                           
                        });
                    }
                });
            })(jQuery);           
            $(document).ready(function() {
                $('.selectAll').checkboxes({
                    itemChild: 'chk'
                });
            });
            </script>            
        </apex:pageBlock>  
    </apex:form> 
</apex:page>

please check it  if it is rightUser-added imageI




I want this table it working properly but when i am send the mail it not working please help me