• Milan Vadhia
  • NEWBIE
  • 24 Points
  • Member since 2016
  • Salesforce Engineer

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 10
    Replies
Hello I have written test class for following apex trigger. But it is giving an error. Can anyone help me with the same?

Trigger
 
trigger AccountTrigger on Account (after insert, after update, before insert, before update) {
    if(Trigger.isAfter){
        if(Trigger.isInsert){
            AccountTrigger_Helper obj_AccountTrigger_Helper = new AccountTrigger_Helper();
            obj_AccountTrigger_Helper.getGeoLocation(Trigger.new);
        }
    }
 if(System.IsBatch() == false && System.isFuture() == false){ 
  if(Trigger.isAfter){
        if(Trigger.isupdate){
            AccountTrigger_Helper obj_AccountTrigger_Helper = new AccountTrigger_Helper();
            obj_AccountTrigger_Helper.getGeoLocation(Trigger.new);
        }
    }
    }
}
Trigger Handler Apex:
 
global class AccountTrigger_Helper {
    
    public void getGeoLocation(List<Account> listAccountNew){
          getGeoLocationfuture(listAccountNew[0].Id); 
    }
    
    @future (callout=true)
    public static void getGeoLocationfuture(Id AccountId){
        
        //Get all the account records available in salesforce, using Id received in parameter of future method.
        String account_query = 'SELECT id, distance__c, geopointe__Geocode__r.geopointe__Latitude__c, geopointe__Geocode__r.geopointe__Longitude__c, description'; 
                account_query += ' FROM Account WHERE Id != \''+AccountId+'\' LIMIT 10000';
        
        List<Account> accList = database.query(account_query);
        
        //Get Newly inserted Account Record, which fired this trigger, using Id received in parameter of future method.
        List<Account> NewListAccount = [SELECT id,
                                               distance__c,
                                               geopointe__Geocode__r.geopointe__Latitude__c,
                                               geopointe__Geocode__r.geopointe__Longitude__c,
                                               description 
                                          FROM Account
                                         WHERE Id =: AccountId];
        
        Account objAccount = NewListAccount[0];
        
        //geopointe instance
        geopointe.API.DistanceService ds = new geopointe.API.DistanceService();
        
        //Add Newly inserted Account as origin for all instances. and add other accounts as Destination using for loop variable.
        for(Integer i = 0; i < accList.size(); i++){
            ds.add((Double)objAccount.geopointe__Geocode__r.geopointe__Latitude__c,
                        (Double)objAccount.geopointe__Geocode__r.geopointe__Longitude__c,
                        (Double)accList.get(i).geopointe__Geocode__r.geopointe__Latitude__c,
                        (Double)accList.get(i).geopointe__Geocode__r.geopointe__Longitude__c);
        }
        
        /******************************************************************/
        List<Nearest_Accounts__c> nearest_Accounts_insert_list = new List<Nearest_Accounts__c>();
        List<Account_Distance_Wrapper> get_Distance_Sorted_list = new List<Account_Distance_Wrapper>();
        
        for(Integer i = 0; i < accList.size(); i++){
            System.debug('=====accList======'+accList[i]);
            Double Distance = ds.getDistanceAtIndex(i);
            System.debug('=====Distance======'+Distance);
            Account_Distance_Wrapper AccDistanceWrapper = new Account_Distance_Wrapper(accList[i].Id, AccountId, Distance);
            
            get_Distance_Sorted_list.add(AccDistanceWrapper);
        }
        
        get_Distance_Sorted_list.sort();
        
        for(Integer i = 0; i < 10; i++){
            Nearest_Accounts__c objNearestAccount = new Nearest_Accounts__c();
            
            objNearestAccount.Account__c = get_Distance_Sorted_list[i].Account_Id;
            objNearestAccount.Near_By_Account__c = get_Distance_Sorted_list[i].NearAccountId;
            objNearestAccount.Distance__c = get_Distance_Sorted_list[i].Distance;
            
            System.debug('=====objNearestAccount======'+objNearestAccount);
            nearest_Accounts_insert_list.add(objNearestAccount);
        }
        
        if(nearest_Accounts_insert_list.size() > 0){
            insert nearest_Accounts_insert_list;
        }
    }
}
Test class which I wrote but giving an error:
 
@isTest
private class Test_Account_Trigger {

	private static testMethod void Account_Trigger_Test() {
	    
	    List<Account> listAccount = new List<Account>();
	    List<geopointe__Geocode__c> listGeopointe = new List<geopointe__Geocode__c>();
	    
	    Account acc = new Account(Name='mapAccount');
	    insert acc;
	    
	    for(Integer i = 0; i < 20; i++){
	        Account objAccouont = new Account();
	        objAccouont.Name = 'Test Account '+i;
	       // objAccouont.geopointe__Geocode__c = listGeopointe[i].Id;
            
            listAccount.add(objAccouont);
	    }
	    insert listAccount;
	    
	    for(Integer i = 0; i < 20; i++){
    	    geopointe__Geocode__c insert_geopointe = new geopointe__Geocode__c();
    	    insert_geopointe.geopointe__Latitude__c = 23.0645200 + i - 0.5;
    	    insert_geopointe.geopointe__Longitude__c = 72.5427600;
    	    insert_geopointe.geopointe__Map_Object__c = 'account_all';
    	    insert_geopointe.geopointe__Parent_Record_Id2__c = listAccount[i].Id;
    	    insert_geopointe.geopointe__Parent_Record_ID__c = listAccount[i].Id;
    	    
    	    listGeopointe.add(insert_geopointe);
	    }
	    insert listGeopointe;
	    
	    for(Integer i = 0; i < listAccount.size(); i++){
	        listAccount[i].geopointe__Geocode__c = listGeopointe[i].Id;
	    }
	    update listAccount;
	    
	    test.startTest();
	    
	    Account insertAccount = new Account();
	    
	    insertAccount.Name = 'Test Insert';
	    insertAccount.geopointe__Geocode__c = listGeopointe[10].Id;
	    
	    insert insertAccount;
	    
	    insertAccount.Name = 'Test Update';
	    update insertAccount;
	    
	    test.stopTest();
	}

}

Please, Help me to solve this error. Thank you.

 
Hello,

I want to send Visualforce page as pdf in email for e-sign using Adobe EchoSign When clicked on command button on Visualforce page. This Visualforce page contains data from multiple objects. How can I send this page for signature using Adobe EchoSign? Please help asap.
How can I write Test class for the given Apex class?

Apex Class:
public with sharing class logCallCtrl{
    public Task followUpTask        {   get;set;    } 
    public Boolean isFollowup       {   get;set;    }
    private ApexPages.StandardController stdController;
    public logCallCtrl(ApexPages.StandardController stdController){
        String whoId = ApexPages.currentPage().getParameters().get('who_id');
        String sobjectName = String.isNotBlank(whoId) ? Id.valueOf(whoId).getSObjectType().getDescribe().getName() : '';
        this.stdController = stdController;
        Task objTask = (Task)stdController.getRecord();
        objTask.Status = 'Completed';
        objTask.OwnerID = Userinfo.getUserId();
        objTask.Subject = 'Call';
        objTask.WhatId = ApexPages.currentPage().getParameters().get('what_id');
        objTask.WhoId = sobjectName == 'Lead' || sobjectName == 'Contact' ? objTask.WhoId : null;
        isFollowup = false;  
        followUpTask = new Task(Status = 'Open', OwnerID = Userinfo.getUserId(), Subject = 'Call Follow-up', WhatId=objTask.WhatId, WhoId=objTask.WhoId);
    }
    
    public PageReference save(){  
        String retURL = apexpages.currentpage().getparameters().get('retURL');  
        stdController.save();
        if(isFollowup){
            if(followUpTask.OwnerID == null){
                ApexPages.Message errorMessage1 = new ApexPages.Message(ApexPages.Severity.ERROR,'\'Assigned To\' can not be blank.');
                ApexPages.Message errorMessage2 = new ApexPages.Message(ApexPages.Severity.ERROR,'If you do not want to add Follow-up Task, uncheck \'Add follow-up task?\'');
                ApexPages.addMessage(errorMessage1);
                ApexPages.addMessage(errorMessage2);
                return null;
            } 
            insert followUpTask;
        }
        return String.isNotBlank(retURL) ? new PageReference(retURL) : new PageReference('/'+stdController.getId());
    }
   
}

Visualforce Page:
<apex:page title="Log a Call" standardController="Task" tabStyle="Task" extensions="logCallCtrl">
    <apex:sectionHeader title="Log a Call" subtitle="Log a Call" help="/apex/help page"/>
    <apex:form id="formId">
        <apex:pageMessages />
        <apex:pageBlock id="pageBlockTask" title="Task Edit">
            <div style="border: 0px solid rgb(0,191,255); width:100%;height:23px; background:#CEF6F5;">
                <p style="margin-left:20px;">
                    <table width="100%">
                        <tr><td align="left" width="50%"><B>Task Information </B></td><td align="right" width="30%"><b><span style="color:red;">|</span> = Required Information</b></td></tr>
                    </table>
                </p>
            </div>
            <apex:pageBlockSection id="pbs" columns="2" collapsible="false" >
                <apex:inputField value="{!Task.Subject}" required="true"/>
                <apex:outputLabel />
                <apex:inputField value="{!Task.OwnerId}"/>
                <apex:inputField value="{!Task.ActivityDate}"/>
                <apex:inputField value="{!Task.WhoId}"/>
                <apex:inputField value="{!Task.WhatId}"/>
                <apex:outputField value="{!Task.Status}"/>
                <apex:inputField value="{!Task.Type}" required="true"/>
                <apex:inputField value="{!Task.Description}"/>
            </apex:pageBlockSection>
            <br/>
            <apex:actionRegion >
                <apex:inputCheckbox id="chkbox" value="{!isFollowup}"><b>Add follow-up task?</b>
                     <apex:actionsupport event="onclick" rerender="oppanel"/>
                </apex:inputCheckbox>
                <apex:outputPanel id="oppanel">
                     <apex:outputPanel rendered="{!isFollowup}">
                         <div style="border: 0px solid rgb(0,191,255); width:100%;height:23px; background:#CEF6F5;">
                            <p style="margin-left:20px;">
                                <table width="100%">
                                    <tr>
                                        <td align="left" width="50%"><b>Schedule follow-up task</b></td>
                                        <td align="right" width="30%" style="text-align:right;">
                                        </td>
                                    </tr>
                                </table>
                            </p>
                        </div>
                        <div style="border: 0px solid rgb(0,191,255); width:100%;height:23px; background:#CEF6F5;"><p style="margin-left:20px;">
                            <table width="100%">
                                <tr><td align="left" width="50%"><B>Task Information </B></td><td align="right" width="30%"><b><span style="color:red;">|</span> = Required Information</b></td></tr>
                            </table></p>
                        </div>                
                        <apex:pageBlockSection id="pbs2" columns="2" collapsible="false" >
                            <apex:inputField value="{!followUpTask.Subject}" />
                            <apex:outputLabel />
                            <apex:inputField value="{!followUpTask.OwnerId}" required="false"/>
                            <apex:inputField value="{!followUpTask.ActivityDate}"/>
                            <apex:inputField value="{!followUpTask.WhoId}"/>
                            <apex:inputField value="{!followUpTask.WhatId}"/>
                            <apex:inputField value="{!followUpTask.Status}"/>
                            <apex:inputField value="{!followUpTask.Type}" />
                            <apex:inputField value="{!followUpTask.Description}"/>
                        </apex:pageBlockSection>
                    </apex:outputPanel>
                </apex:outputPanel>
            </apex:actionRegion>
            <apex:pageBlockButtons >
                <apex:commandButton Value="Save" action="{!save}" />
                <apex:commandButton Value="Cancel" action="{!Cancel}" />
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Hello, I have a query and tried searching a solution over google and salesforce developers forums too. But I am not able to get the solution.

We all are talking how to manipulate whatId of Task SObject. but no one explained about the dropdown list shown in related To field (What field).

What should I do to retrieve all those objects which are displayed in related to field pick list in task object.

I have added sceen shots to explain what I want to get.

Please do help.

Thank you.

User-added image


User-added image

I want all these objects to be retrieved.
Hello, I am trying to improve given controller class. Can anybody tell me how can I improve given controller class for this VF page which is redirected from account using custom button. I want to improve this class code as per coding standards.

Thank you.
 
ManageContacts.vfp
<apex:page standardController="Account" extensions="ManageContactController" >
    <div style="position:absolute;top:15px;left: 50%;">
        <apex:actionStatus id="actionProcess" >
            <apex:facet name="start" >
                <apex:image url="{!$Resource.Load_white}" height="40px" />
            </apex:facet>
        </apex:actionStatus>
    </div>
    <apex:form > 
    	<apex:pageBlock title="Contacts of Account : {!account.Name}" id="contactList">
    	    <apex:pageBlockButtons >
                <apex:commandButton action="{! saveAll }" value="Save all"/>
                <apex:commandButton action="{! cancel }" value="Cancel"/>
            </apex:pageBlockButtons>
             <apex:variable value="{!0}" var="rowNum"/> 
            <!--<apex:pageBlockSection columns="5">-->
                <apex:pageBlockTable id="pb1" value="{!listContacts}" var="contact" align="center">
                    <apex:column headerValue="Action" >
                        <apex:commandButton action="{!deleteRow}" value="Delete" immediate="true" reRender="contactList" status="actionProcess">
                            <apex:param value="{!rowNum}" name="rowNumId" assignTo="{!rowNumId}"/>
                        </apex:commandButton>
                        <apex:variable var="rowNum" value="{!rowNum + 1}" />
                    </apex:column>    
      	        	<apex:column headerValue="First Name"><apex:inputField value="{!contact.FirstName}" /></apex:column>
      	    	    <apex:column headerValue="Last Name"><apex:inputField value="{!contact.LastName}"/></apex:column>
      	        	<apex:column headerValue="Phone"><apex:inputField value="{!contact.Phone}"/></apex:column>
      	    	    <apex:column headerValue="Email"><apex:inputField value="{!contact.Email}"/></apex:column>
   		        </apex:pageBlockTable>
   		        <br/><apex:commandLink value="Add Contact Row" action="{!addContactRow}" immediate="true" reRender="contactList" status="actionProcess"/>
            <!--</apex:pageBlockSection>-->
	    </apex:pageBlock>
    </apex:form>
</apex:page>

ManageContactController.apxc

public class ManageContactController {
    public List<Contact> listContacts       {   get;set;    }
    public List<Contact> deleteContacts  = new List<Contact>();
    public Set<Contact> CompareContacts = new Set<Contact>();    
    private Account objAccount;
    public ManageContactController(ApexPages.StandardController stdController){
        objAccount = (Account) stdController.getRecord();
        listContacts = getContacts(objAccount.Id);
        compareContacts.addAll(listContacts);
    }
    // To fatch contacts from database using AccountId
    private List<Contact> getContacts(String accountId){
        return [SELECT Id, 
                       FirstName, 
                       LastName, 
                       Phone, 
                       Email 
                  FROM Contact 
                 WHERE AccountId =:accountId];
    }
    // To add new row to table
    public void AddContactRow(){
        listContacts.add(new Contact(AccountId = objAccount.Id));
    }
    // To update database
    public void saveAll(){
        List<Contact> listContactsAdd = new List<Contact>();
        for(Contact objContact : listContacts ) if(objContact.LastName !=null) listContactsAdd.add(objContact);
        upsert listContactsAdd;
        if(! deleteContacts.isEmpty()) delete deleteContacts;
    }
    // To delete row from table
    public void deleteRow(){
        Integer rowId = Integer.valueOf(apexpages.currentpage().getparameters().get('rowNumId'));
            if(compareContacts.contains(listContacts.get(rowId))) deleteContacts.add(listContacts.get(rowId));
            listContacts.remove(rowId);
    }
}

As I am new in salesforce, please someone help me to write a test class for this given triggers..... Thank you.
ContactTrigger.apxt
trigger ContactTrigger on Contact (after insert, after update, after delete, after undelete) {

// Trigger to Insert contact Name from Contact CSV field of Account    
     if(Trigger.isInsert){
         if(Trigger.isAfter){
             ContactHandler insertContact = new ContactHandler();
             insertContact.onAfterInsert(Trigger.new);
        }
     }

// Trigger to Update contact Name from Contact CSV field of Account    
     if(Trigger.isUpdate){
         if(Trigger.isAfter){
             ContactHandler updateContact = new ContactHandler();
             updateContact.onAfterUpdate(Trigger.new , Trigger.oldMap);
        }
     }
     
// Trigger to Delete contact Name from Contact CSV field of Account 
     if(Trigger.isDelete){
         if(Trigger.isAfter){
             ContactHandler deleteContact = new ContactHandler();
             deleteContact.onAfterDelete(Trigger.old);
        }
     }
    
// Trigger to Undelete contact Name from Contact CSV field of Account    
     if(Trigger.isUndelete){
         if(Trigger.isAfter){
             ContactHandler undeleteContact = new ContactHandler();
             undeleteContact.onAfterUndelete(Trigger.new);
        }
     }
}   // End of Trigger ContactTrigger

ContactHandler.apxc
-----------------------------
public class ContactHandler {
    
    // Insert Trigger Handler Class
    public void onAfterInsert(List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }      // End of onAfterInsert Class

    // Update Trigger Handler Class
    public void onAfterUpdate(List<Contact> lstContact , Map<Id, Contact> mapContactOld){
        updateContactNameOnAccount(lstContact, mapContactOld);
    }      // End of onAfterUpdate Class

    // Delete Trigger Handler Class
    public void onAfterDelete(List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }      // End of onAfterDelete Class

    // Delete Trigger Handler Class
    public void onAfterUndelete (List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }   // End of onAfterUndelete Class
    
    private void updateContactNameOnAccount(List<Contact> lstContactNew, Map<Id, Contact> mapContactOld){
        Set<Id> setAccountId = new Set<Id>();
        for(Contact objContact : lstContactNew){
            if(mapContactOld.containskey(objContact.Id)) setAccountId.add(mapContactOld.get(objContact.Id).AccountId);
            setAccountId.add(objContact.AccountId);
        }
        List<Account> lstAccount = new List<Account>();
        for(Account objAccount : [SELECT Id, (SELECT Id, Name FROM Contacts) FROM Account WHERE Id IN: setAccountId]){
            List<String> lstContactName = new List<String>();
            for(Contact objContact : objAccount.Contacts){ 
                lstContactName.add(objContact.Name);
            }
            objAccount.Contact_CSV__c = String.join(lstContactName, ', ');
            lstAccount.add(objAccount);
        }
        update lstAccount;
    }
}   // End of ContactTriggerHandler Class


 
Hello,

I want to send Visualforce page as pdf in email for e-sign using Adobe EchoSign When clicked on command button on Visualforce page. This Visualforce page contains data from multiple objects. How can I send this page for signature using Adobe EchoSign? Please help asap.
Hello, I have a query and tried searching a solution over google and salesforce developers forums too. But I am not able to get the solution.

We all are talking how to manipulate whatId of Task SObject. but no one explained about the dropdown list shown in related To field (What field).

What should I do to retrieve all those objects which are displayed in related to field pick list in task object.

I have added sceen shots to explain what I want to get.

Please do help.

Thank you.

User-added image


User-added image

I want all these objects to be retrieved.
Hello, I am trying to improve given controller class. Can anybody tell me how can I improve given controller class for this VF page which is redirected from account using custom button. I want to improve this class code as per coding standards.

Thank you.
 
ManageContacts.vfp
<apex:page standardController="Account" extensions="ManageContactController" >
    <div style="position:absolute;top:15px;left: 50%;">
        <apex:actionStatus id="actionProcess" >
            <apex:facet name="start" >
                <apex:image url="{!$Resource.Load_white}" height="40px" />
            </apex:facet>
        </apex:actionStatus>
    </div>
    <apex:form > 
    	<apex:pageBlock title="Contacts of Account : {!account.Name}" id="contactList">
    	    <apex:pageBlockButtons >
                <apex:commandButton action="{! saveAll }" value="Save all"/>
                <apex:commandButton action="{! cancel }" value="Cancel"/>
            </apex:pageBlockButtons>
             <apex:variable value="{!0}" var="rowNum"/> 
            <!--<apex:pageBlockSection columns="5">-->
                <apex:pageBlockTable id="pb1" value="{!listContacts}" var="contact" align="center">
                    <apex:column headerValue="Action" >
                        <apex:commandButton action="{!deleteRow}" value="Delete" immediate="true" reRender="contactList" status="actionProcess">
                            <apex:param value="{!rowNum}" name="rowNumId" assignTo="{!rowNumId}"/>
                        </apex:commandButton>
                        <apex:variable var="rowNum" value="{!rowNum + 1}" />
                    </apex:column>    
      	        	<apex:column headerValue="First Name"><apex:inputField value="{!contact.FirstName}" /></apex:column>
      	    	    <apex:column headerValue="Last Name"><apex:inputField value="{!contact.LastName}"/></apex:column>
      	        	<apex:column headerValue="Phone"><apex:inputField value="{!contact.Phone}"/></apex:column>
      	    	    <apex:column headerValue="Email"><apex:inputField value="{!contact.Email}"/></apex:column>
   		        </apex:pageBlockTable>
   		        <br/><apex:commandLink value="Add Contact Row" action="{!addContactRow}" immediate="true" reRender="contactList" status="actionProcess"/>
            <!--</apex:pageBlockSection>-->
	    </apex:pageBlock>
    </apex:form>
</apex:page>

ManageContactController.apxc

public class ManageContactController {
    public List<Contact> listContacts       {   get;set;    }
    public List<Contact> deleteContacts  = new List<Contact>();
    public Set<Contact> CompareContacts = new Set<Contact>();    
    private Account objAccount;
    public ManageContactController(ApexPages.StandardController stdController){
        objAccount = (Account) stdController.getRecord();
        listContacts = getContacts(objAccount.Id);
        compareContacts.addAll(listContacts);
    }
    // To fatch contacts from database using AccountId
    private List<Contact> getContacts(String accountId){
        return [SELECT Id, 
                       FirstName, 
                       LastName, 
                       Phone, 
                       Email 
                  FROM Contact 
                 WHERE AccountId =:accountId];
    }
    // To add new row to table
    public void AddContactRow(){
        listContacts.add(new Contact(AccountId = objAccount.Id));
    }
    // To update database
    public void saveAll(){
        List<Contact> listContactsAdd = new List<Contact>();
        for(Contact objContact : listContacts ) if(objContact.LastName !=null) listContactsAdd.add(objContact);
        upsert listContactsAdd;
        if(! deleteContacts.isEmpty()) delete deleteContacts;
    }
    // To delete row from table
    public void deleteRow(){
        Integer rowId = Integer.valueOf(apexpages.currentpage().getparameters().get('rowNumId'));
            if(compareContacts.contains(listContacts.get(rowId))) deleteContacts.add(listContacts.get(rowId));
            listContacts.remove(rowId);
    }
}

As I am new in salesforce, please someone help me to write a test class for this given triggers..... Thank you.
ContactTrigger.apxt
trigger ContactTrigger on Contact (after insert, after update, after delete, after undelete) {

// Trigger to Insert contact Name from Contact CSV field of Account    
     if(Trigger.isInsert){
         if(Trigger.isAfter){
             ContactHandler insertContact = new ContactHandler();
             insertContact.onAfterInsert(Trigger.new);
        }
     }

// Trigger to Update contact Name from Contact CSV field of Account    
     if(Trigger.isUpdate){
         if(Trigger.isAfter){
             ContactHandler updateContact = new ContactHandler();
             updateContact.onAfterUpdate(Trigger.new , Trigger.oldMap);
        }
     }
     
// Trigger to Delete contact Name from Contact CSV field of Account 
     if(Trigger.isDelete){
         if(Trigger.isAfter){
             ContactHandler deleteContact = new ContactHandler();
             deleteContact.onAfterDelete(Trigger.old);
        }
     }
    
// Trigger to Undelete contact Name from Contact CSV field of Account    
     if(Trigger.isUndelete){
         if(Trigger.isAfter){
             ContactHandler undeleteContact = new ContactHandler();
             undeleteContact.onAfterUndelete(Trigger.new);
        }
     }
}   // End of Trigger ContactTrigger

ContactHandler.apxc
-----------------------------
public class ContactHandler {
    
    // Insert Trigger Handler Class
    public void onAfterInsert(List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }      // End of onAfterInsert Class

    // Update Trigger Handler Class
    public void onAfterUpdate(List<Contact> lstContact , Map<Id, Contact> mapContactOld){
        updateContactNameOnAccount(lstContact, mapContactOld);
    }      // End of onAfterUpdate Class

    // Delete Trigger Handler Class
    public void onAfterDelete(List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }      // End of onAfterDelete Class

    // Delete Trigger Handler Class
    public void onAfterUndelete (List<Contact> lstContact){
        updateContactNameOnAccount(lstContact, new Map<Id, Contact>());
    }   // End of onAfterUndelete Class
    
    private void updateContactNameOnAccount(List<Contact> lstContactNew, Map<Id, Contact> mapContactOld){
        Set<Id> setAccountId = new Set<Id>();
        for(Contact objContact : lstContactNew){
            if(mapContactOld.containskey(objContact.Id)) setAccountId.add(mapContactOld.get(objContact.Id).AccountId);
            setAccountId.add(objContact.AccountId);
        }
        List<Account> lstAccount = new List<Account>();
        for(Account objAccount : [SELECT Id, (SELECT Id, Name FROM Contacts) FROM Account WHERE Id IN: setAccountId]){
            List<String> lstContactName = new List<String>();
            for(Contact objContact : objAccount.Contacts){ 
                lstContactName.add(objContact.Name);
            }
            objAccount.Contact_CSV__c = String.join(lstContactName, ', ');
            lstAccount.add(objAccount);
        }
        update lstAccount;
    }
}   // End of ContactTriggerHandler Class


 

Hello,

 

I have some doubts around EchoSign App, If anyone has already worked on it or having any experience, Please help me for following scenarios!

 

1) I have a scenario where I want to send the Opportunity data with the Agreement for eSignature. so how can I achieve this?

 

2) When the I will get the Agreement after Signature, I want to extract the Signature of that document & store it on Perticular Detail page like as
in "Authorized By" section of another object.

 

Thanks accolades!

  • September 27, 2013
  • Like
  • 0