Posts

Showing posts from September, 2015

How to remove and Delete row from PageBlock table on VF page

<apex:page controller="Classname" sidebar="false">    <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 id="frmId"> <apex:actionstatus id="statusProcessing" startstyleclass="Processing"></apex:actionstatus> <apex:pageBlock id="blockTD"> <apex:variable var="delrowNumber" value="{!0}"/>  <apex:pageBlockTable value="{!lstofData}" var="objTB"> <apex:column headerValue="Action"> <apex:commandLink value="Del" style="color:red" action="{!delRow}" immediate="true" reRender="blockTD" status="statusProcessing" > <ap

Only Number enter in Input text on VF page

Using javascript you can validate only number will be enter in text box <apex:page> <script>    function numbersonly(e)         {              var unicode=e.charCode? e.charCode : e.keyCode;                if (unicode!=8 )             {                  if ((unicode<48||unicode>57))                        return false;                              }                   }                       </script> <apex:form> <apex:inputText value="{!xxx}" onkeypress="return numbersonly(event);"> </apex:form> <apex:page>   Sumit Shukla sumitshukla.mca@gmail.com skypeID: shuklasumit1 Mob:9711055997

Roll up Contact on Account

trigger updateContactCountonAccount on Contact (after insert,after Delete) { Set<ID> setofAccId = new Set<Id>(); Map<Id,List<Contact>> MapAccIDTOListOfCont = new Map<Id,List<Contact>>(); Map<ID,Account> MapIDToAccount = new Map<Id,Account>(); if(Trigger.isAfter && Trigger.isInsert) { for(Contact ObjCOn: trigger.new) { if(ObjCOn.AccountId !=null) { setofAccId.add(ObjCOn.AccountId); } } } if(Trigger.isAfter && Trigger.isDelete) { for(Contact ObjCOn: trigger.old) { if(ObjCOn.AccountId !=null) { setofAccId.add(ObjCOn.AccountId); } } } for(Account objAcc:[Select Id from Account where ID IN:setofAccId]) { MapIDToAccount.put(objAcc.ID,objAcc); } for(Contact objCon:[Select id , Name,AccountId from Contact where Accou

Remove "-None-" value from Visualforce Page in Standard and Custom Pick List Values

Solution  There are Two Solution to  Remove "-None-" value from salesforce standard and custom Selected Picklist field. 1) Do "Required" In Visualforce Page means Required= "true" or On Pagelayout Required CheckBox true. 2) Using Jquery <apex:page standardController="Case">     <apex:form>         <script type='text/javascript' src= '//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'>         </script>         <script language="javascript">             $(function() {                         $('select.RemoveNoneValue option[value=]').remove();                    });         </script>             <apex:inputField styleClass="RemoveNoneValue" value="{!Case.Status__c}"/>     </apex:form> </apex:page> Thanks Sumit Shukla sumitshukla.mca@gmail.com

Number to Word Apex Code

Public Class NumberToWordClass {   public String ru{get;set;}   public Void NumberToWord(Integer no)     {                        ru='';         String[] word = new List<String>         {            '',' ONE ',' TWO ',' THREE ',' FOUR ',' FIVE ',' SIX ',' SEVEN ',' EIGHT ',' NINE ',' TEN ',           ' ELEVEN ',' TWELVE ',' THIRTEEN ',' FOURTEEN ',' FIFTEEN ',' SIXTEEN ',' SEVENTEEN ',' EIGHTEEN ',' NINETEEN '         };         String[] tens = new List<String>         {         '','','TWENTY','THIRTY','FORTY','FIFTY','SIXTY','SEVENTY','EIGHTY','NINETY'         };           Integer n1,n2;           n1=math.mod(no,100);           if(n1>0)           {               if(n1<=19)               {          

Fetch All Account in SOQL without any Contacts.

Fetch All Account in SOQL without any Contacts. List<Account> lst=[SELECT Id                     from Account where ID NOT IN                    (Select AccountID from Contact) limit 1]; system.debug('lst****'+lst);

Get Max Value from Decimal List

List<Decimal> lstofDecimalValues = new List<Decimal>(); lstofDecimalValues.add(55.0); lstofDecimalValues.add(75.5); lstofDecimalValues.add(99.3); Decimal maxvalue = lstofDecimalValues[1];  system.debug('maxvalue***'+maxvalue);         For (integer i =0;i<lstofDecimalValues.size();i++)         {                          if( lstofDecimalValues[i] > maxvalue)                 maxvalue = lstofDecimalValues[i];  system.debug('maxvaluellll'+maxvalue);                     }     system.debug('the max value is'+maxvalue);

Send Birthday Email to Contacts Using Apex Code

// This is Class for Sending the Birthday Email with using Custom Template // Schedule this class weekly every morning  public  class SendBirthdayWishesEmail {          Public void sendBirthdayMail()     {           //Get date and Month from Today Date          Date thisDate = system.Today();         Integer SysDay = thisDate.Day(); // Get Day from 1 to 31         Integer SysMonth = thisDate.month(); //get Month from 1 to 12         String SysDayAndSysMont = SysDay +'/'+SysMonth; // get Day and Month                               Map<string,EmailTemplate> mapNameToEmailTemplate = new Map<string,EmailTemplate>();        // OrgWideEmailAddress replyEmail = [SELECT ID, DisplayName FROM OrgWideEmailAddress WHERE Address =: 'sumitshukla.mca@gmail.com'];                  for(EmailTemplate emailTemp : [Select id ,subject,body,DeveloperName,HtmlValue  from EmailTemplate where DeveloperName = 'Email Template Name']) // Firstly you need to c

How to use Comparable Interface in Salesforce

Image
The Comparable interface use for sorting : Lists that contain non-primitive data types, that is, Lists of user-defined types. In Apex you need to implement the Comparable interface with its compareTo method in your class. When a class implements the Comparable interface it has to implement a method called compareTo().  In this method the code has to be verified if two objects match or if one is larger than the other. Class Code global class  CamprableInterfaceExampleController {     public List<WrapperClass> WrapperList {get;set;}        public CamprableInterfaceExampleController () {         WrapperList = new List<WrapperClass>();         WrapperClass s1 = new WrapperClass('Sumit', 22);         WrapperList.add(s1);                  WrapperClass s2 = new WrapperClass ('Amit', 15);         WrapperList.add(s2);                  WrapperClass s3 = new WrapperClass ('Rahul', 55);         WrapperList.add(s3);                  Wrapp