Wednesday, 6 August 2014

Types of Sandboxes

Types of Sandboxes
Salesforce now providing four types of sandboxes.
1. Developer Sandbox
2. Developer Pro Sandbox
3. Partial Data Sandbox
4. Full Sandbox
Developer Sandbox
Developer sandbox is a copy of production, it copies all application and configuration information to the sandbox. This type of sandboxes limited to 200MB of test or sample data, which is enough for many development and testing tasks. You can refresh a developer sandbox once per day.
Developer Pro Sandbox
Developer Pro sandboxes copy all of your production organization’s reports, dashboards, price books, products, apps, and customizations under Setup, but exclude all of your organization’s standard and custom object records, documents, and attachments. This type of sandboxes limited to 1GB of test or sample data. We can refresh developer pro type sandboxes once per day.
Partial Data Sandbox
A Partial Data sandbox is a Developer sandbox plus the data you define in a sandbox template. It includes the reports, dashboards, price books, products, apps, and customizations under Setup (including all of your metadata). Additionally, as defined by your sandbox template, Partial Data sandboxes can include your organization’s standard and custom object records, documents, and attachments up to 5 GB of data and a maximum of 10,000 records per selected object. A Partial Data sandbox is smaller than a Full sandbox and has a shorter refresh interval. You can refresh a Partial Data sandbox every 5 days.
Sandbox templates allow you to pick specific objects and data to copy to your sandbox, so you can control the size and content of each sandbox. Sandbox templates are only available for Partial Data or Full sandboxes.
Full Copy Sandbox
Full copy sandboxes are exact copy of production including standard and custom objects records, attachments and documents. You can refresh full copy sandbox every 29 days.

Tuesday, 5 August 2014

Salesforce Summer ’14 Release Notes

1. Change sets included in the Deployment Status Page.
2. Notes & Attachments & Files size Limit Increased 5MB to 25MB.
3. Limit Raised for External IDs from 3 to 7.

Salesforce Release Months


Spring = February, 
Summer=June,
Winter=October.

Tuesday, 15 July 2014

Best Practices of Test Classes in Apex


  • Use Test.startTest() to reset Governor limits in Test methods
  • If you are doing any Asynchronous operation in code, then don’t forget to callTest.stopTest() to make sure that operation is completed.
  • Use System.runAs() method to enforce OWD and Profile related testings. This is very important from Security point of view.
How to write Test method of Controller Extension for StandardController ?
Example :
//Lets Assume we are writing Controller Extension for Account
Account acct = [SELECT ID FROM Account LIMIT 1];

//Start Test Context, It will reset all Governor limits
Test.startTest();

//Inform Test Class to set current page as your Page where Extension is used
Test.setCurrentPage(Page.YOUR_PAGE);

//Instantiate object of "ApexPages.StandardController" by passing object
ApexPages.StandardController stdController = new ApexPages.StandardController(acct);

//Now, create Object of your Controller extension by passing object of standardController
YOUR_Extension ext = new YOUR_Extension(stdController);

//Here you can test all public methods defined on Extension "ext"
//..... your code

//Finish Test
Test.stopTest();

Monday, 23 June 2014

Based on Picklist Visible Lookup Field


Here "Risk Assessment" is a Picklist and "Peer Reviewer" is a Lookup field.

<apex:pageBlockSectionItem >
 <apex:outputLabel value="Risk Assessment"></apex:outputLabel>
  <apex:actionRegion>
   <apex:inputField value="{!thisCon.theCase.Risk_Assessment__c}" rendered="{!thisCon.caseRTN       ame == 'OD Change'}"> 
    <apex:actionSupport event="onchange" rerender="pr,prr" />      
  </apex:inputField>
 </apex:actionRegion>
</apex:pageBlockSectionItem>
  
<apex:pageBlockSectionItem >
 <apex:outputLabel value="Peer Reviewer"></apex:outputLabel>
  <apex:outputPanel id="pr"> 
   <apex:outputPanel rendered="{!if(thisCon.theCase.Risk_Assessment__c != null,true,false)}"> 
   <apex:inputField value="{!thisCon.theCase.Peer_Reviewer__c}" rendered="{!thisCon.caseRTNam        e == 'OD Change'}" required="true"/>
  </apex:outputPanel>
 </apex:outputPanel> 
</apex:pageBlockSectionItem>


This is another way:-


 <apex:actionRegion >
  <apex:inputField value="{!thisCon.theCase.Risk_Assessment__c}" required="true" rendered="{!     thisCon.caseRTName == 'OD Change'}">  
   <apex:actionSupport event="onchange" rerender="pr,rp" />      
  </apex:inputField>   
 </apex:actionRegion>
   
 <apex:pageBlockSectionItem >
  <apex:outputPanel id="rp" >
   <apex:outputText value="Risk Assessment" rendered="{!if(thisCon.theCase.Risk_Assessment__c       != null,true,false)}"/>
  </apex:outputPanel> 

 <apex:outputPanel id="pr">
  <apex:outputPanel rendered="{!if(thisCon.theCase.Risk_Assessment__c != null,true,false)}">
   <apex:inputField value="{!thisCon.theCase.Peer_Reviewer__c}" rendered="{!thisCon.caseRTNam         e == 'OD Change'}" />
  </apex:outputPanel>
 </apex:outputPanel>  
</apex:pageBlockSectionItem>


Friday, 13 June 2014

Using Schedulable interface Testclass

@isTest 
public class ContractAmendmentLinkageTestClass{
@isTest static void Amendment(){
ContractAmendmentLinkage Contractobj = new ContractAmendmentLinkage ();
String sch = '20 30 8 10 2 ?';
String jobID = system.schedule('ContractAmendmentLinkage JOB', sch, Contractobj);

Datetime sysTime = System.now().addSeconds( 300 );     
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
System.Schedule('SelfSchedule ' + sysTime, chronExpression, new ContractAmendmentLinkage() );
  }
}



sch: Is the corn expression ,the corn expression is nothing but the next scheduled time.
ContractAmendmentLinkage JOB: is the name of the job.

Contractobj:: is the object of the scheduled class which we need to run.
corn expression for to run schedule(ContractAmendmentLinkage) every 5min. below

// This is Self-Schedule To Execution purpose.

(Datetime sysTime = System.now().addSeconds( 300 );   
String chronExpression = '' + sysTime.second() + ' ' + sysTime.minute() + ' ' + sysTime.hour() + ' ' + sysTime.day() + ' ' + sysTime.month() + ' ? ' + sysTime.year();
System. Schedule( 'SelfSchedule ' + sysTime, chronExpression, new ContractAmendmentLinkage() );)

Thursday, 12 June 2014

Refreshing the formula field based on text field using Trigger.

Refreshing the fields based on text field(FX Rate to usd) parent to child will refresh(Calculations using formula field) parent.

Parent to child to parent updation using trigger.

Trigger:-

trigger Fieldupdations on Opportunity_Margin_Template__c (after update) {
List<Opportunity_Margin_Template__c> templist = new List<Opportunity_Margin_Template__c>();
List<Opportunity_Template_Task__c> templatetasklist = new List<Opportunity_Template_Task__c>();
set<id> setid = new set<id>();
for(Opportunity_Margin_Template__c margin: Trigger.new)
{
 setid.add(margin.id);
}
List<Opportunity_Margin_Template__c> tasklist = [select Id,Name,Template_Save_as__c,FX_Rate_to_USD__c from Opportunity_Margin_Template__c
                                                 where id in:setid];
templatetasklist =[select id, Cost_Hr__c,Opportunity_Margin_Template__c from   Opportunity_Template_Task__c where  Opportunity_Margin_Template__r.id In : setid];                                        
for(Opportunity_Margin_Template__c temp: tasklist)
{
 if(temp.FX_Rate_to_USD__c!=Trigger.oldmap.get(temp.Id).FX_Rate_to_USD__c)
 {
   templist.add(temp);
 }
}
update templatetasklist ;      
update templist;                                                                                
             

}