Posts

Showing posts from December, 2014

Manage Order of Trigger Execution in Salesforce for Object

Hi guys, Note: Handle the trigger order of execution: If any Case when you required to write 4 triggers on different - different events but on same object then don't write 4 trigger for same. Suppose you have 4 trigger on Account Object. 1- AccTrigger1.trigger 2- AccTrigger2.trigger 3- AccTrigger3.trigger 4- AccTrigger4.trigger Solution is mention as below STEP 1- Create only one trigger for one object(Account) like- In above case instead of having 5 triggers on  STEP 2- Create only 1 trigger that is AccountTrigger.trigger on Account Object. // Create Trigger as Mention Below trigger AccountTrigger on Account (after insert, after update, before delete, before insert, before update)  {     AccortunityTriggerHandler triggerHandler = new AccortunityTriggerHandler(Trigger.isExecuting,Trigger.size);         if(Trigger.isBefore && Trigger.isInsert){         triggerHandler.OnBeforeInsert(trigger.new, trigger.NewMap);     }         if(Trigger.isAft

How to Increment Sr No on Visual force Page

<apex:page>     <apex:form >             <table style="width:auto;margin-top:10px;" border="1" cellspacing="0" cellpadding="0" >                 <tr>                     <td  style="background-color:lightblue;font-weight:bold;vertical-align:bottom;text-align:center;width:34px;"> Sr.No </td> <td  style="background-color:lightblue;font-weight:bold;vertical-align:bottom;text-align:center;width:34px;"> Name</td>                 </tr>             </table>                 <apex:variable value="{!0}" var="Count"/>                              <table id="tblInfo" style="width:auto;border-top: 0;" border="1"  cellspacing="0" cellpadding="0" >                     <tbody>                            <apex:repeat value="{!lstWrapper}" var="wrap">   

Batch Class and Dynamic Create Email Template

global  class batchClasAndSendDynamicEmailTemplate implements Database.Batchable<Sobject> {     set<Id> suid= new set<Id>();     set<id> sweekplanid = new set<id>();     map<id,user> mapManager = new map<id,user>();     Map<ID,List<Weekly_Plan__c>> mapUserIdToAWPList = new Map<Id,List<Weekly_Plan__c>>();     Map<ID,String> mapUserIdToManagerEmail = new Map<Id,String>();      Map<ID,String> mapManagerIdTomanager = new Map<Id,String>();      list<string> lstEmail = new list<string>();     string tempBody = '';     List<Weekly_Plan__c> listPJPWeeklyUpdate = new List<Weekly_Plan__c>();          global Database.Querylocator start(Database.Batchablecontext BC)     {         return Database.getQueryLocator([Select Is_Rejected__c,                                                 No_of_Day_Plan__c,                                                  Status__c, 

Dynamic SOQL Query

String qString = 'Select Id , Name , FirstName , LastName , Account.Name , Kips_Designation__c , Kips_Relationship__c , Birthdate , Kips_Date_of_Anniversary__c , Kips_Feast_Date__c , Kips_Annual_Gift__c From Contact ';                  qString+= ' where Account.Name like \'%' + AccountName+ '%\'';                             if(objGift.kips_Type__c !=null && objGift.kips_Type__c !='')         {             if(objGift.kips_Type__c == 'School')             {                 //qString+= ' and Account.RecordType.Name like \'%' + objGift.kips_Type__c+ '%\'';                      qString+= ' and Account.RecordType.Name  =  \'' + objGift.kips_Type__c+ '\'';                 qString+= ' and Kips_CURRENT_SCHOOL_Active__c = \'Yes\'';                         qString+=' and Kips_Key_Person__c = true';              }             if(objGift.kips_Type__c == 

On Custom Button VF page Open in new Tab

{!REQUIRESCRIPT("/soap/ajax/15.0/connection.js")} var accId="{!Account.Id}"; window.open("/apex/vfpageName?id="+ accId ,"mywindow");

Show Loading Image on Change Event using Action Status

<div dir="ltr" style="text-align: left;" trbidi="on"> <span style="background-color: #d2eaf1; color: #222222; font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: bold;">High Value Payments</span><b><style> .Processing         {             position: fixed;             background: url('/img/loading32.gif');             background-repeat: no-repeat;             background-position: center;                         width: 100%;             height: 100%;             z-index: 1004;             left: 0%;             top: 0%;         } </style> <apex:form> <apex:actionstatus id="statusProcessing" startstyleclass="Processing"> <apex:commandbutton action="{!onClickSave}" oncomplete="scroll(0, 2);" rerender="idoutPanlMsg" status="statusProcessing" value="Save"> </apex:commandbutto

How to Calculate Sum of Amount and Pass Date Value in Url

if( Apexpages.currentPage().getParameters().get('date') != null && Apexpages.currentPage().getParameters().get('date') != '' ) { string strDate= Apexpages.currentPage().getParameters().get('date'); string[] arrDate = strDate.split('-'); if( arrDate.size() > 2 ) objProject.start_Date__c=date.newInstance( integer.valueof( arrDate[0] ), integer.valueof( arrDate[1] ), integer.valueof( arrDate[2] ) ); } Calculate some of Amount  // Declare Variable {!TEXT(ROUND(Total_due,0))} Total {!TEXT(ROUND(GrandTotal,0))}

Update Record on Custom Button Using JavaScript on Detail Page

{!REQUIRESCRIPT("/soap/ajax/19.0/connection.js")}  var DayPlanRecord = new sforce.SObject("Object Name");  DayPlanRecord.id = "{!ObjectName.Id}";  DayPlanRecord.FieldName = false ;  var recordType = sforce.connection.query("Select ID,FieldName, Name From ObjectName where FieldName = false " );  DayPlanRecord.FieldName = true ; result = sforce.connection.update([DayPlanRecord]);  window.location.reload();