Posts

Showing posts from January, 2023

Email Template Send Email Example 2

 Trigger leadAssignment on Lead (after insert, after update) {     if(Trigger.isUpdate){         if(Trigger.isAfter){             Set<Id> LeadsOwnerIds = New Set <Id>();             for (Lead leadRec : Trigger.new) {                 if (leadRec.OwnerId != Trigger.oldMap.get(leadRec.Id).OwnerId) {                     LeadsOwnerIds.add(leadRec.OwnerId);                 }                 system.debug('LeadsOwnerIds '+LeadsOwnerIds);             }             List <string> emailLst = New List <String> ();             List <User> UserLst = [Select Id,Name,Email from user where Id In : LeadsOwnerIds];    ...

Convert Date Format In apex salesforce

-----------------------------------------------------------------------------------------------------------------------   Formula No. 1  ----------------------------------------------------------------------------------------------------------------------- String crDate;  dateTime d = logSheet.CreatedDate;  crDate = (d == null) ? '-' : d.day()+ '/' + d.month() + '/' + d.year(); System.debug(crDate); ----------------------------------------------------------------------------------------------------------------------- Formula No. 2 ----------------------------------------------------------------------------------------------------------------------- String crDate; date d = logSheet.CreatedDate;  crDate = (d == null) ? '-' : d.format('yyyy/MM/dd'); System.debug(crDate); -----------------------------------------------------------------------------------------------------------------------

How to create Test Class Example

---------------------------------------------------------------------------------------------------------------------- This is a Test Class Example ---------------------------------------------------------------------------------------------------------------------- @isTest public class CaseLineItemsQACloneCtrlTest {     @TestSetup     public static void TestSetup(){         string recordTypeId = Schema.SObjectType.Account.getRecordTypeInfosByName().get('OEM').getRecordTypeId();         Account acc = new Account();         acc.Name='testAcc';         acc.RecordTypeId = recordTypeId;         insert acc;                  Account acc1 = new Account();         acc1.Name ='testAcc1';         acc1.RecordTypeId = recordTypeId;         insert acc1;       ...