Iteration Order for Maps and Sets Is Now Predictable (Summer 15 Release Update)

Hi Guys,

  1. Until this Spring 15 release, Maps and Sets are Unordered Collections. So the returned order will be random.
  2. But beginning from Summer 15 release onwards, Maps and Set order is predictable. The order will be same that what you put from the beginning to end.
 Map<String, String> orderedMap = new Map<String, String>();
 orderedMap.put('Good', 'This is so good');
 orderedMap.put('Bad', 'This is so bad');

If you run the above code snippet in Developer console you will get the returned order as below,

Until Spring 15 Release:

{Bad=This is so bad, Good=This is so good}

From Summer 15 Release:

{Good=This is so good, Bad=This is so bad}

This changes is not the API level, this is Schema level change. If anyone relying on the Map or Set order in your codes, change it as soon.

Different Ways Of Using Apex:Param Tag


What Is Parm Tag?
<apex:Param> :- apex:param tag is used to hold java Script values.
param means parameter. This tag is also used to Pass values from 
java Script to an Apex controller. 

The <apex:param> component can only be a child of the following components:

  • <apex:actionFunction>
  • <apex:actionSupport>
  • <apex:commandLink>
  • <apex:outputLink>
  • <apex:outputText>
  • <flow:interview>


 <apex:param name="ParamName" value"{!someValue}" assignTo="{!someproperty}"/> 

value : Required = T R U E

Ques)So, When To Use assingTo & value And How To Use It?
If you use value u can set the value to the query string param name like

<apex:param name="ParamName" value"1234"/> 

& Now, You can access this value in the controller using

Integer res=apexpages.currentpage().getparameters.get('ParamName');


If you use assingTo attribute then this will asigen the value to a property in the controller.
In Visualforce Page:

 <apex:param name="ParamName" value"{!someValue}" assignTo="{!someproperty}"/> 

In The Controller:

public string someproperty {get;set;} 

Now The Value What is Present in Value shall be assign to someproperty



<apex:page controller="paramexample">
 <apex:form >
 <apex:pageblock >
<apex:pageblockTable title="Accounts" value="{!acclist}" var="a">
<apex:column headervalue="Account name">
<apex:commandlink reRender="out" action="{!Paramdemo}">
<apex:param name="aid" value="{!}" assignTo="{!accname}"/>
<apex:column value="{!}"/>
<apex:column value="{!a.industry}"/>

<apex:outputpanel id="out">
accname = {!accname}

public class paramexample
public string accname{get;set;}
public list<account> acclist { get; set; }

public paramexample(){
acclist = new list<account>();
for(account a : [select id, name, phone, industry from account limit 20])

public void Paramdemo() {}


param example

ssing  param example

Click This To Know  Passing Parameters Using Javascript & ActionFunction


Automatically shows the Choose file Option / Button when a checkbox is selected.

whenever I select/check the checkbox (checkbox value=true) then the ChooseFile (inputfile) should display/show automatically .

Vf code:

<apex:page controller="example23">

<apex:form >

 <apex:inputCheckbox value="{!option}" >
<apex:actionsupport event="onclick" action="{!change}" />

<apex:actionRegion rendered="{!bool}">

<apex:inputFile value="AttachFile" />



Apex Controller:

public class example23 {

 public Boolean bool { get; set; }
 public Boolean option { get; set; }
 public PageReference change() {
 if(option == true)
 bool = true; 
 bool = false; 
 return null;

public example23(){
bool =false;


To hide  tag

Using Trigger Updating Lookup filed.

To Update the Lookup field, Using Trigger Before Insert, Before Update.

Here I’am assuming Opportunity as Child and Budget_Master__c as Parent Object.
The Criteria is The From_Date__c(Date filed) & To_Date__c(Date filed) From Budget_Master__c must be in the range of given Opportunity RecCreatedDate__c(Datetime field)

trigger UpdateLookup on Opportunity (Before Insert,Before update) {
if(trigger.isInsert || trigger.isUpdate){
set<Budget_Master__c> BudMaster = new Set<Budget_Master__c>([Select Id, Name, From_Date__c,To_Date__c From Budget_Master__c]);

for(Opportunity  Op :{
for(Budget_Master__c BM :BudMaster ){
system.debug('------BFR IF---- ');
system.debug('------RecCreatedDate : '+(Op.RecCreatedDate__c).date());
 system.debug('------From: ' +BM.From_Date__c);
 system.debug('------ToDt: '+BM.To_Date__c );
If(  (((Op.RecCreatedDate__c).date()) >= BM.From_Date__c) && ((Op.RecCreatedDate__c).date()) <=(BM.To_Date__c)) {
system.debug('------InSide IF---- ');
}//If closed
}//Inner for CLOSED
}//outer for CLOSED
}//if(trigger.isInsert || trigger.isUpdate) CLOSED
}//Trigger closed

Capitalize First Name, LastName, and All Address Fields of Account


Trigger On Account Object

trigger ChangingFirstlttrUpper on Account (before insert,before update) {
      if(trigger.isBefore )
         if(trigger.IsInsert ||trigger.IsUpdate )

Apex Class

global class ChanignToCaps{
   global static void Change( Account [] acc){
      for(Account a :acc){
         if(a.Name!=null || a.Name != ' '){
   if(a.BillingStreet != null )
    a.BillingStreet = formatToUpper(a.BillingStreet);

   if(a.BillingCity !=null)
    a.BillingCity = formatToUpper(a.BillingCity);

   if(a.BillingState !=null )
    a.BillingState= formatToUpper(a.BillingState);

   if(a.BillingPostalCode !=null )
    a.BillingPostalCode = formatToUpper(a.BillingPostalCode);

   if(a.BillingCountry !=null )
    a.BillingCountry= formatToUpper(a.BillingCountry);

formatToUpper Is A Static Function Which Does The Acutal Work:

public static String formatToUpper (String Str) {
String result = '';
for (String iter : Str.split('[ ]+')) {
   if (iter != null && iter != '') {
    if (iter.length() > 1) {
     result += iter.substring(0,1).toUpperCase() + iter.substring(1,iter.length()) + ' ';
     result += iter.substring(0,1).toUpperCase() + ' ';
return result;
Capitalize First Name, LastName, and All Address Fields of Account

Capitalize First Name, LastName, and All Address Fields of Account

Displaying Related Records In A Group Wise


<apex:page controller="groupwisedisplay" sidebar="false" title="Displaying Related Records In A Group Wise" showHeader="false">
 <!-- Begin Default Content REMOVE THIS -->
 <h1> Displaying Related Records In A Group Wise </h1>
 <apex:repeat value="{!StartHere}" var="gp">
 <apex:outputText style="color:blue;" value="{!gp.acc.Name}"/>
     <apex:repeat value="{!gp.con}" var="p">
      <li> (Contact) &nbsp;
       <apex:outputText style="color:green" value="{!p.FirstName}"/> &nbsp;
       <apex:outputText style="color:green;" value="{!p.LastName}"/>
    <ul >
     <li ><ol>
      (Case)<apex:repeat value="{!p.Cases}" var="child">
     <li >
      <apex:outputText style="color:gray;" value="{!child.Subject}"/>
 <apex:repeat value="{!gp.opp}" var="p">
 <li> (Opportunity) &nbsp;
 <apex:outputText style="color:red" value="{!p.Name}"/>
 <apex:outputLabel value="Close Date:" for="out1"/>
 <apex:outputText value="{!p.CloseDate}" id="out1"/> <br>
 <apex:outputLabel value="Stage:" for="out2"/>
 <apex:outputText value="{!p.StageName}" id="out2"/></br>


Apex Code/ Controller

public class groupwisedisplay {

public list<wrapgroupwise> singlegroup;
public List<wrapgroupwise> getStartHere(){
singlegroup= new List<wrapgroupwise>();
List<Account> tempacc=[select Id, Name from Account Limit 10];

for(Integer i=0; i<tempacc.size() ; i++){
list <contact> tempcon=[SELECT Id, FirstName, LastName,(SELECT Id, CaseNumber,Subject From Cases) From Contact Where AccountId =:tempacc[i].id Limit 10];
list <Opportunity> tempopp=[SELECT Id,Name,CloseDate,StageName From Opportunity Where AccountId =:tempacc[i].id Limit 10];
singlegroup.add( new wrapgroupwise(tempacc[i],tempcon,tempopp));

return singlegroup ;

 //wrapper class
 public class wrapgroupwise{
 public List<contact> con {get;set;}
 public Account acc {get;set;}
 public List<Opportunity> opp {get;set;}

 public wrapgroupwise( Account a , list<Contact> c,list<Opportunity> o){
 } //end of wrapper class

group wise displaying records

Indian(Vedic) & International Number Conversion – In Word Format

<apex:page controller="NumberSystem" sidebar="false">
 <apex:form >
  <h1> Indian(Vedic) &amp; International Number System - In Word Format </h1>

  <apex:outputLabel for="txt1" value="Enter Number:">
  <apex:inputText value="{!num}" id="txt1" size="17" />

  <apex:selectRadio border="0" legendText="Pick The Conversion Format" value="{!selectedValue}" layout="pageDirection" >
     <apex:selectOption itemLabel="Indian(Vedic) Number System " itemvalue="Indian" />
     <apex:selectOption itemLabel="International Number System" itemvalue="International" />

  <apex:commandButton value="Convert" action="{!NumConvert}" reRender="outpan" status="actstatusId"/>

  <apex:actionStatus id="actstatusId" >
     <apex:facet name="start">
        <img src="/img/loading.gif"/>

  <apex:outputPanel id="outpan">
  <b> {!result} </b>


Apex Code/Controller:

public class NumberSystem {

 public String selectedvalue { get; set; }
 public transient string num { get; set; }
 public transient string result { get; set; }
 public transient string out{get;set;}
 integer i=0,j=1;
 integer flg=0,flg1=1;
 integer length,len;
 public NumberSystemfinal1(){
 //command button
 public PageReference NumConvert() {
     result='Incompatible, Try Numeric Format Only';
          num = string.valueOf(long.valueOf(num));
      } catch(TypeException e){
          System.debug('The Following Exception Occurred:'+e.getMessage());
        }//catch closed
     out=' ';
     if(length > 15)
         result='Number Out Of Range, Max Of 15 Digits Only';
     else if(selectedvalue=='International')
   }//outer else closed
   return null;
 }//NumConvert (CommandButton)Closed

In Indian Conversion

public string indianConversion(){
   length=len; i=0;j=1;
 while(length >= 1)
   if(length==15||length==13||length==11||length==9||length==7||length==5||length==2) {
        i++; j++;
     else if(num.substring(i,j)=='1'){
         out+= twoDigitTeen();
         length--; flg1=flg=1;
         i++; j++;
     }//inner else if closed
          out+= twoDigitzero();
          length--; flg=0;flg1=1;
          i++; j++;
   }//outer if closed
    if(num.substring(i,j)=='0' && flg1==0)
    }//else closed
  }//outer if closed
   if(length==14 && flg1==1)
    out+=' Neel ';
   else if(length==12 && flg1==1)
    out+=' Kharab ';
   else if(length==10 && flg1==1)
    out+=' Arab ';
   else if(length==8 && flg1==1)
    out+=' Crore ';
   else if(length==6 && flg1==1)
    out+=' Lakhs ';
   else if(length==4 && flg1==1)
    out+=' Thousand ';
   else if(length==3){
           out+=' Hundreed ';
 }//while closed
 return out;
}//indianConvertion Closed

In International Conversion

 public string internationalConversion(){
  out=''; flg1=1;
  length=len; i=0;j=1;
  while(length >= 1){
       } else
      length--; i++;j++;
    }//if closed
       if(num.substring(i,j)=='0' && flg1==1){
          i++; j++;
       else if(num.substring(i,j)=='1'){
           out+= twoDigitTeen();
           length--; flg=1; flg1=0;
           i++; j++;
       }//inner else if closed
           out+= twoDigitzero();
           length--; flg=0;flg1=0;
           i++; j++;
      }//else closed
    }//outer if closed 

   If((length/3==1||length==1)&& (flg==0)){
       if((num.substring(i,j)=='0') && (flg1==1))
       }//outer else closed
   }//outer if closed
   if(length==13 && flg1==0)
       out+=' Trillion ';
   else if(length==10 && flg1==0)
       out+=' Billion ';
   else if(length==7 && flg1==0)
       out+=' Million ';
   else if(length==4 && flg1==0)
       out+=' Thousand ';
  } //while closed
  return out;
}//internationalConvertion closed

//Code for Calculating Two Digit Non Zero Numbers

public String twoDigitTeen(){
 transient string temp;
    temp = ' Eleven ';
 else if(num.substring(i+1,j+1)=='2')
    temp =' Twelve ';
 else if(num.substring(i+1,j+1)=='3')
    temp = ' Thirteen ';
 else if(num.substring(i+1,j+1)=='4')
    temp = ' Fourteen ';
 else if(num.substring(i+1,j+1)=='5')
    temp =' Fifteen ';
 else if(num.substring(i+1,j+1)=='6')
    temp =' Sixteen ';
 else if(num.substring(i+1,j+1)=='7')
    temp =' Seventeen ';
 else if(num.substring(i+1,j+1)=='8')
    temp =' Eighteen ';
 else if(num.substring(i+1,j+1)=='9')
    temp =' Ninteen ';
 else if(num.substring(i+1,j+1)=='0')
    temp =' Ten ';
 else temp='';
 return temp;
}//twoDigitTeen ends

//Code for Calculating Two Digit  Zero Numbers

public string twoDigitzero(){
 transient string temp;
    temp =' Twenty ';
 else if(num.substring(i,j)=='3')
    temp =' Thirty ';
 else if(num.substring(i,j)=='4')
    temp =' Fourty ';
 else if(num.substring(i,j)=='5')
    temp =' Fifty ';
 else if(num.substring(i,j)=='6')
    temp =' Sixty ';
 else if(num.substring(i,j)=='7')
    temp =' Seventy ';
 else if(num.substring(i,j)=='8')
    temp =' Eighty ';
 else if(num.substring(i,j)=='9')
    temp =' Ninty ';
 else temp='';
return temp;
}//twoDigitzero ends

//Code for Calculating Single Digit  Numbers

public string singleDigits(){
 transient string temp;
   temp =' One ';
 else if(num.substring(i,j)=='2')
   temp =' Two ';
 else if(num.substring(i,j)=='3')
   temp =' Three ';
 else if(num.substring(i,j)=='4')
   temp =' Four ';
 else if(num.substring(i,j)=='5')
   temp =' Five ';
 else if(num.substring(i,j)=='6')
   temp =' Six ';
 else if(num.substring(i,j)=='7')
   temp =' Seven ';
 else if(num.substring(i,j)=='8')
   temp =' Eight ';
 else if(num.substring(i,j)=='9')
   temp =' Nine ';
 else temp= '';
return temp;
}//singleDigits ends
}//controller closed

NUMBER To Word Conversion