Posts

Showing posts from September 11, 2015

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