Wednesday, 26 August 2015

VF Pages

What is Visualforce page?
Visualforce is very interesting framework in Salesforce. It is a markup language you can use this to develop user interface according to your requirements in Salesforce. Visualforce runs on Force.com platform

To create and view Visualforce page in Salesforce, check the below link

http://www.infallibletechie.com/2014/08/how-to-create-and-view-visualforce-page.html
How to override Add to Campaign button in Salesforce?
1. Create a VF page with standardController="CampaignMember".

Sample Code:

<apex:page standardController="CampaignMember" extensions="Sample">
</apex:page>

2. Go to Setup --> Build --> Customize --> Campaigns --> Buttons, Links, and Actions.
http://2.bp.blogspot.com/-3xV8G74pBqQ/VX6Ze_SuwWI/AAAAAAAAG6M/KMTdUEKgNGQ/s1600/Campaigns%2Bbuttons.png

3. Click Edit.
http://1.bp.blogspot.com/-oFZO-A2YFGc/VX6ZeyYrryI/AAAAAAAAG6g/tLFIuAjlcBo/s1600/Edit%2BAdd%2Bto%2BCampaign.png


4. Select the VF page created.
http://2.bp.blogspot.com/-Xb9fuIZDMXk/VX6Ze4qh9FI/AAAAAAAAG6c/eecuJ67_eTE/s1600/override%2Bwith%2BVF%2Bpage.png

Cheers!!!
Labels: Apex and Visualforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to show profile photo in Visuaforce page?
Sample Code:

Visualforce page:


<apex:page controller="Sample">
<apex:pageBlock >
<apex:image value="{!photoURL}"/>
</apex:pageBlock>
</apex:page>

Apex Controller:

public class Sample {
public String photoURL {get;set;}

public sample() {

photoURL = [SELECT Id, smallPhotoURL FROM User WHERE ID =: UserInfo.getUserId()].smallPhotoURL;
}


}

Output:

http://4.bp.blogspot.com/-IPXqC1ffMVs/VWbhdTK8uvI/AAAAAAAAGv4/WY_FrFy-4p4/s1600/profile%2Bphoto%2Bon%2Bvf%2Bpage.png

apex:vote Example
Go to Ideas tab and create an idea.

Sample Visualforce page:


<apex:page id="thePage">
<apex:form >
<apex:vote objectId="087U00000004ZU7"></apex:vote>
</apex:form>
</apex:page>

here "087U00000004ZU7" is id of an idea created.

Output:
http://4.bp.blogspot.com/-BEdXEYS16os/VVx-FNnwSlI/AAAAAAAAGqY/IH_cUgJvy08/s1600/apex%2Bvote.png

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Toolbar using apex in Salesforce
Sample Code:

<apex:page id="thePage">
<apex:toolbar id="theToolbar">
<apex:outputText value="Sample Toolbar"/>
<apex:toolbarGroup itemSeparator="line" id="toobarGroupLinks">
<apex:outputLink value="http://www.infallibletechie.com">Infallible Techie</apex:outputLink>
<apex:outputLink value="http://www.salesforce.com">Salesforce</apex:outputLink>
</apex:toolbarGroup>
<apex:toolbarGroup itemSeparator="line" location="right" id="toobarGroupForm">
<apex:form id="theForm">
<apex:inputText id="theInputText">Enter Text: </apex:inputText>
<apex:commandLink value="search" id="theCommandLink"/>
</apex:form>
</apex:toolbarGroup>
</apex:toolbar>
</apex:page>

Output:
http://3.bp.blogspot.com/-2Y6kPX5qHAY/VVx48PvTG-I/AAAAAAAAGqI/Z-HV0cy_H6s/s640/Toolbar.png

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
apex:panelBar example
Sample Code:

<apex:page >
<apex:panelBar >
<apex:panelBarItem label="Item 1">Panel Bar Example 1</apex:panelBarItem>
<apex:panelBarItem label="Item 2">Panel Bar Example 2</apex:panelBarItem>
<apex:panelBarItem label="Item 3">Panel Bar Example 3</apex:panelBarItem>
</apex:panelBar>
</apex:page>

Output:
http://3.bp.blogspot.com/-7Q8T24o9YLw/VVxo_jxetLI/AAAAAAAAGp0/aLpeWcGBmjQ/s1600/apex%2BpanelBar.png


http://1.bp.blogspot.com/-1YZpVgbiJ6Y/VVxo_xTDrxI/AAAAAAAAGpw/biy0ciHW4dE/s1600/panel%2Bbar.png

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to find insert or update using Apex in Salesforce?
Sample Code:

Visualforce Page:


<apex:page standardController="Account" extensions="Sample">
<apex:form >
<apex:pageMessage rendered="{!NOT(updateBool)}" severity="info">Insert</apex:pageMessage>
<apex:pageMessage rendered="{!updateBool}" severity="info">Update</apex:pageMessage>
</apex:form>

</apex:page>

Apex Class:


public class Sample {
public Boolean updateBool {get;set;}

public Sample(ApexPages.StandardController controller) {
Account a = (Account)controller.getRecord();
updateBool = a.Id == null ? false : true;
}
}

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Hyperlink field to open Visualforce page from related list in Salesforce?
Sample Code:

Visualforce page:


<apex:page controller="Sample" tabStyle="Account">
<apex:form >
<apex:pageMessages />
<apex:pageBlock id="pg">
<apex:pageBlockSection columns="1">
<apex:outputField value="{!con.FirstName}"/>
<apex:outputField value="{!con.LastName}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

Apex Class:


public class Sample {
public Contact con {get;set;}
Id conId {get;set;}

public Sample() {
conId = ApexPages.currentPage().getParameters().get('conId');
con = [SELECT FirstName, LastName FROM Contact WHERE Id =: conId];
}

}

Field:
http://4.bp.blogspot.com/-cmpieB0T7HQ/VTkPpFKCVBI/AAAAAAAAGXY/8-a0mMg-P9w/s1600/formula%2Bfield.png

http://3.bp.blogspot.com/-uF1L31dYJ0A/VTkPpJ7OQdI/AAAAAAAAGXc/KVWGIthRA1Q/s1600/hyper%2Blink%2Bfield.png


Output:

http://4.bp.blogspot.com/-AaXMUiytNJM/VTkP0PrNYcI/AAAAAAAAGXo/cv-PXnd1PPI/s1600/hyperlink%2Bfield%2Bopen.png

http://4.bp.blogspot.com/-XKbFALxe_Dc/VTkPeDF8oaI/AAAAAAAAGXQ/ycZe2Ltxaic/s1600/output%2Bof%2Bhyperlink%2Bfield.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
What is the difference between outputfield and outputtext?
apex:outputText: Displays text on a Visualforce page.

apex:outputField:
A read-only display of a label and value for a field on a Salesforce object.

Sample Code:


Visualforce Page:


<apex:page controller="Sample" tabStyle="Account">
<apex:form >
<apex:pageMessages />
<apex:pageBlock id="pg">
<apex:pageBlockSection columns="1">
<apex:outputText >Sample Output Text</apex:outputText>
<apex:outputField value="{!acct.Name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

Apex Class:


public class Sample {
public Account acct {get;set;}

public Sample() {
acct = [SELECT Name, Industry FROM Account LIMIT 1];
}
}


Output:
http://4.bp.blogspot.com/-SVVcWLHjJPU/VTkETNcTt8I/AAAAAAAAGXA/1t8LL49tTm8/s1600/outputText%2Band%2BoutputFiel.png

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Sample Wrapper Class using Apex in Salesforce
Sample Code:

Visualforce Page:


<apex:page controller="Sample" tabStyle="Account">
<apex:form >
<apex:pageMessages />
<apex:pageBlock id="pg">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!listWrapper}" var="a">
<apex:column >
<apex:inputCheckbox value="{!a.checkBool}"/>
</apex:column>
<apex:column value="{!a.acct.Name}"/>
<apex:column value="{!a.acct.Industry}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex Controller:

public class Sample {
public List<WrapperClass> listWrapper {get;set;}

public Sample() {
List<Account> listAcct = [SELECT Name, Industry FROM Account LIMIT 1000];

if(listAcct.size() > 0) {
listWrapper = new List<WrapperClass>();

for(Account a : listAcct) {
listWrapper.add(new WrapperClass(a));
}
}
}

public class WrapperClass {
public Boolean checkBool {get;set;}
public Account acct {get;set;}
public WrapperClass(Account acct) {
this.acct = acct;
}
}
}

Output:
http://1.bp.blogspot.com/-CbYj1ky9zhE/VRBLTLL3D5I/AAAAAAAAGJc/_k9z-gCY0kk/s1600/salesforce%2Bwrapper%2Bclass.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Simple Search using Visualforce and Apex in Salesforce?
Sample Code:

Visualforce page:


<apex:page controller="Sample" tabStyle="Account">
<apex:actionstatus id="actStatus">
<apex:facet name="start">
<div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
<div class="waitingHolder" style="top: 100px; width: 91px;">
<img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
<span class="waitingDescription">Loading...</span>
</div>
</div>
</apex:facet>
</apex:actionstatus>
<apex:form >
<apex:pageMessages />
<apex:pageBlock id="pg">
<apex:pageBlockSection >
<apex:panelGrid columns="3" cellpadding="3" cellspacing="3">
<apex:outputLabel value="Account Name: "/>
<apex:inputText value="{!acctName}"/>
<apex:commandButton value="Go" action="{!searchAcct}" status="actStatus" reRender="pg"/>
</apex:panelGrid>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!listAcctOptions.Size > 0}" title="Account Selection">
<apex:panelGrid columns="2">
<apex:outputLabel value="Select Account: "/>
<apex:selectList value="{!selectedAcctId}" size="1">
<apex:selectOptions value="{!listAcctOptions}"/>
<apex:actionSupport action="{!fetchRecords}" event="onchange" status="actStatus" reRender="pg"/>
</apex:selectList>
</apex:panelGrid>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!listContacts.Size > 0}" title="Contacts">
<apex:pageBlockTable value="{!listContacts}" var="con">
<apex:column >
<apex:outputLink target="_blank" value="/{!con.Id}">{!con.Name}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!listOpptys.Size > 0}" title="Opportunities">
<apex:pageBlockTable value="{!listOpptys}" var="oppty">
<apex:column >
<apex:outputLink target="_blank" value="/{!oppty.Id}">{!oppty.Name}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockSection rendered="{!listCases.Size > 0}" title="Cases">
<apex:pageBlockTable value="{!listCases}" var="cas">
<apex:column >
<apex:outputLink target="_blank" value="/{!cas.Id}">{!cas.CaseNumber}</apex:outputLink>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>

Apex Controller:


public class Sample {
public String acctName {get;set;}
public List<SelectOption> listAcctOptions {get;set;}
public List<Contact> listContacts {get;set;}
public List<Case> listCases {get;set;}
public List<Opportunity> listOpptys {get;set;}
public String acctId {get;set;}
public String selectedAcctId {get;set;}

public Sample() {
listAcctOptions = new List<SelectOption>();
listContacts = new List<Contact>();
listCases = new List<Case>();
listOpptys = new List<Opportunity>();
}

public void searchAcct() {
String soql = 'SELECT Id, Name FROM Account WHERE Name LIKE \'' + acctName + '%\' LIMIT 999';
List<Account> listAcct = Database.query(soql);
system.debug('Test ' + listAcct);
if(listAcct.size() > 0) {
listAcctOptions = new List<SelectOption>();
listAcctOptions.add(new SelectOption('none', '-----------None-----------'));
for(Account a : listAcct) {
listAcctOptions.add(new SelectOption(a.Id, a.Name));
}
}
}

public void fetchRecords() {
if(selectedAcctId != 'none') {
listOpptys = [SELECT Id, Name FROM Opportunity WHERE AccountId =: selectedAcctId];
listContacts = [SELECT Id, Name FROM Contact WHERE AccountId =: selectedAcctId];
listCases = [SELECT Id, CaseNumber FROM Case WHERE AccountId =: selectedAcctId];
} else {
ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR,'Select an Account to fetch their records'));
}
}
}

Output:

http://2.bp.blogspot.com/-VVwDgNlVTDE/VPi_Ryt5aHI/AAAAAAAAGHI/cS0t211fqBE/s1600/search%2Bin%2BSalesforce.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
Rendering based on Object access in Salesforce
$ObjectType.ObjectName.accessible - Check whether the user has access to the object.

$ObjectType.ObjectName.createable - Check whether the user has create access to the object.

$ObjectType.ObjectName.updateable - Check whether the user has update or edit access to the object.

$ObjectType.ObjectName.deletable - Check whether the user has delete access to the object.

Sample Code:

<apex:page >
<apex:form >
<apex:pageBlock rendered="{!$ObjectType.Employee__c.accessible}">
<!-- Code to show components that should be visible only to to users who has access to Employee object -->
</apex:pageBlock>
<apex:pageBlock rendered="{!$ObjectType.Employee__c.createable}">
<!-- Code to show components that should be visible only to to users who has create access to Employee object -->
</apex:pageBlock>
<apex:pageBlock rendered="{!$ObjectType.Employee__c.updateable}">
<!-- Code to show components that should be visible only to to users who has update access to Employee object -->
</apex:pageBlock>
<apex:pageBlock rendered="{!$ObjectType.Employee__c.deletable}">
<!-- Code to show components that should be visible only to to users who has delete access to Employee object -->
</apex:pageBlock>
</apex:form>
</apex:page>

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
2 comments:
http://img1.blogblog.com/img/icon18_email.gif
Footer right align in apex:pageBlockTable Salesforce
The CSS style float:right;, helps in Footer right align in apex:pageBlockTable.

Sample Code:


Visualforce page:


<apex:page docType="html-5.0" controller="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockTable value="{!listAccount}" var="a">
<apex:column value="{!a.Name}"/>
<apex:column value="{!a.AnnualRevenue}" style="text-align:right;">
<apex:facet name="footer">
<apex:outputText value="${0, number, ###,###,###,##0.00}" style="float:right;">
<apex:param value="{!totalRevenue}" />
</apex:outputText>
</apex:facet>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>

</apex:page>

Controller:


public class Sample {
public List<Account> listAccount {get;set;}
public Double totalRevenue {get;set;}
public Sample() {
totalRevenue = 0;
listAccount = [SELECT Name, AnnualRevenue FROM Account];
calculateTotalRevenue();
}
private void calculateTotalRevenue() {
for(Account acct : listAccount) {
if(acct.AnnualRevenue != null)
totalRevenue += acct.AnnualRevenue;
}
}
}

Output:

http://3.bp.blogspot.com/-JAjlXAa6ckc/VLjnAzxIoII/AAAAAAAAF7k/bE1KZgts1L4/s1600/right%2Balign%2Bin%2Bfooter.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
apex:detail in Apex in Salesforce
Sample Code:

Visualforce page:


<apex:page controller="Sample">
<apex:form >
<h1>Below is the Account detail</h1>
<apex:detail subject="{!AccountId}" relatedList="false"/>
</apex:form>

</apex:page>

Apex Controller:


public class Sample {
public Id AccountId {get;set;}

public Sample() {
AccountId = '0019000001BoVNx';
}
}

Output:

http://4.bp.blogspot.com/-B7zHNZC2V3k/VK_fRDPN5iI/AAAAAAAAFzk/PjuV3JXEGi0/s1600/apex%2Bdetail%2Bin%2Bsalesforce.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to call apex method on enter key press in Salesforce?
Sample Code:

<apex:page>

<script type='text/javascript'>

function noenter(ev) {
if (window.event && window.event.keyCode == 13 || ev.which == 13) {
callAcctRet();
return false;
} else {
return true;
}
}
</script>

<apex:form>

<apex:actionFunction action="{!retToAcct}" name="callAcctRet"/>

<apex:inputText value="{!firstName}" onkeypress="return noenter(event);"/>
<apex:form>
</apex:page>

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Save and New feature using Apex in Salesforce
Visualforce page:

<apex:page standardController="Contact" extensions="Sample">
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New" action="{!saveAndNew}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:inputField value="{!Contact.FirstName}"/>
<apex:inputField value="{!Contact.LastName}"/>
<apex:inputField value="{!Contact.Email}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex Class:


public class Sample {
ApexPages.StandardController sController;
public Sample(ApexPages.StandardController controller) {
sController = controller;
}

public PageReference saveAndNew() {

sController.save();
PageReference pg = new PageReference('/apex/Sample');
pg.setRedirect(true);
return pg;
}
}

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
How to add from PageBlockTable to another PageBlockTable in Visualforce page?
Sample Code:

Visualforce page:


<apex:page id="pg" controller="Sample">
<apex:actionstatus id="counterStatus">
<apex:facet name="start">
<div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
<div class="waitingHolder" style="top: 100px; width: 91px;">
<img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
<span class="waitingDescription">Loading...</span>
</div>
</div>
</apex:facet>
</apex:actionstatus>
<apex:form >
<apex:variable var="rowNum" value="{!0}" />
<apex:pageBlock id="addList">
<apex:variable var="rowNum" value="{!0}" />
<apex:pageBlockTable value="{!listAccount}" var="acct">
<apex:column value="{!acct.Name}"/>
<apex:column value="{!acct.Industry}"/>
<apex:column >
<apex:commandLink value="Add" action="{!addToList}" reRender="addList, removeList" status="counterStatus">
<apex:param value="{!rowNum}" name="index" />
</apex:commandLink>
<apex:variable var="rowNum" value="{!rowNum+1}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:outputPanel id="removeList">
<apex:variable var="rowNum1" value="{!0}" />
<apex:pageBlock rendered="{! IF(listAccountAdded.size > 0, true, false)}">
<apex:variable var="rowNum1" value="{!0}" />
<apex:pageBlockTable value="{!listAccountAdded}" var="acc">
<apex:column value="{!acc.Name}"/>
<apex:column value="{!acc.Industry}"/>
<apex:column >
<apex:commandLink value="Remove" action="{!removeFromList}" reRender="addList, removeList" status="counterStatus">
<apex:param value="{!rowNum1}" name="index1" />
</apex:commandLink>
<apex:variable var="rowNum1" value="{!rowNum1+1}"/>
</apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:outputPanel>
</apex:form>
</apex:page>

Apex Controller:

public class Sample {
public List<Account> listAccount {get;set;}
public List<Account> listAccountAdded {get;set;}
public Integer rowNum {get;set;}
public Integer rowNum1 {get;set;}

public Sample() {
listAccount = [SELECT Name, Industry FROM Account];
listAccountAdded = new List<Account>();
}

public void addToList() {
rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
listAccountAdded.add(listAccount.get(rowNum));
listAccount.remove(rowNum);
}

public void removeFromList() {
rowNum1 = Integer.valueOf(apexpages.currentpage().getparameters().get('index1'));
listAccount.add(listAccountAdded.get(rowNum1));
listAccountAdded.remove(rowNum1);
}

}

Output:

http://2.bp.blogspot.com/-DZ7Y1pZc5xE/VH3VjcYlLGI/AAAAAAAAFkw/2FnrL_LY32E/s1600/one%2Bpageblocktable%2Bto%2Banother.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Action Status on radio button change in Salesforce
Sample Code:

Visualforce Page:


<apex:page id="pg">
<apex:actionstatus id="counterStatus">
<apex:facet name="start">
<div class="waitingSearchDiv" id="el_loading" style="background-color: #fbfbfb; height:100%;opacity:0.65;width:100%;">
<div class="waitingHolder" style="top: 100px; width: 91px;">
<img class="waitingImage" src="/img/loading.gif" title="Please Wait..." />
<span class="waitingDescription">Loading...</span>
</div>
</div>
</apex:facet>
</apex:actionstatus>
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Gender"/>
<apex:selectRadio >
<apex:selectOption itemLabel="Male" itemValue="m"/>
<apex:selectOption itemLabel="Female" itemValue="f"/>
<apex:actionSupport event="onchange" status="counterStatus" reRender="pg"/>
</apex:selectRadio>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Output:

http://1.bp.blogspot.com/-C5abk83eU6M/VHhUBhyHGEI/AAAAAAAAFis/cnBD8c3MJeA/s1600/action%2Bstatus%2Bon%2Bradio%2Bbutton.png

Cheers!!!
Labels: Apex and Visualforce, Customization with code in Salesforce, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to read a csv file and show it on a Visualforce page?
Sample Code:

Visualforce Page:


<apex:page controller="Sample">
<apex:form >
<apex:pageBlock id="pg">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Show" action="{!show}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:pageBlockSectionItem >File<apex:inputFile value="{!fileForExport}"/></apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>

<apex:pageBlock rendered="{!showBool}">
<apex:pageBlockTable value="{!listOutput}" var="o">
<apex:repeat value="{!o}" var="i">
<apex:column value="{!i}"/>
</apex:repeat>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex Class:

public class Sample {
public Blob fileForExport {get;set;}
public Boolean showBool {get;set;}
public String output {get;set;}
public List<List<String>> listOutput {get;set;}

public Sample() {

showBool = false;
listOutput = new List<List<String>>();
}

public void show() {
showBool = true;
output = fileForExport.toString();
List<String> tempList = new List<String>();
tempList = output.split('\n');
for(String str : tempList) {
listOutput.add(str.split(','));
}
}
}

Output:
http://4.bp.blogspot.com/-5hxUbpzFmb0/VFRi61BYgdI/AAAAAAAAFZ8/L4E54XW52fY/s1600/csv%2Bin%2Bvf.png

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Visualforce Pages
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Confirm button in Visualforce page in Salesforce
Sample Code:

Visualforce page:


<apex:page controller="SampleController">
<script>
function callSave(){
var r = confirm("Are you sure want to save?");
if(r == true) {
callSav();
}
}
</script>
<apex:form >
<apex:actionFunction name="callSav" action="{!sav}"/>
<apex:pageBlock >
<apex:pageBlockSection >
<apex:inputField value="{!member.Name}"/>
<apex:inputField value="{!member.E_Mail_Id__c}"/>
<apex:inputField value="{!member.State__c}"/>
<apex:inputField value="{!member.City__c}"/>
<apex:inputField value="{!member.Age__c}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Save" onclick="callSave();"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>

Apex controller:

public class SampleController {
public Member__c member {get;set;}
public SampleController() {
member = new Member__c();
}
public void sav(){
insert member;
member = new Member__c();
}
}

Output:

http://2.bp.blogspot.com/-fa_CkyPBMGc/U4YBaFbxL9I/AAAAAAAAEQs/b1S8SBWI7fM/s1600/save.png

http://3.bp.blogspot.com/-ZWBa-oVX-50/U4YBaI0EDNI/AAAAAAAAEQw/cX_7dFnIvS8/s1600/confirm+box.png
Trigger Syntax in Salesforce
Trigger Syntax:

trigger triggerName on ObjectName(events) {
........
........
........
........
........
........
}

here events are before and after events.

Example: before insert, before update, before delete, after insert, after update, after delete, after undelete.

Cheers!!!
Labels: Customization with code in Salesforce, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to update losing lead information to winning Lead in merge in Salesforce
Apex Class:

public class LeadMerge {
@future
public static void updateLeadAfterMerge(Map<Id, String> mapLeadIdLeadSource) {
List<Lead> listLead = new List<Lead>();
for(Id leadId : mapLeadIdLeadSource.keySet()) {
listLead.add(new Lead(Id = leadId, Lead_Source_Detail__c = mapLeadIdLeadSource.get(leadId)));
}
update listLead;
}
}

Trigger:

trigger LeadMergeTrigger on Lead (after delete) {
Map<Id, String> mapLeadIdLeadSource = new Map<Id, String>();
for(Lead l : trigger.old) {
if(String.isNotBlank(l.MasterRecordId)) {
mapLeadIdLeadSource.put(l.MasterRecordId, l.LeadSource);
}
}
if(mapLeadIdLeadSource.size() > 0) {
LeadMerge.updateLeadAfterMerge(mapLeadIdLeadSource);
}
}

Note:

Lead_Source_Detail__c is a custom field created in Lead to capture deleted lead's Lead Source.

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
3 comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to find Case assigned date and time in Salesforce
1. Create a field on Case object with Case_Assigned_Date_Time__c API name.

2. Create a trigger with below code:

trigger CaseTrigger on Case (before insert, before update) {
for(Case c : trigger.new) {
if(trigger.isInsert) {
if(c.Status == 'Assigned') {
c.Case_Assigned_Date_Time__c = System.now();
}
} else if(trigger.isUpdate) {
if(c.Status == 'Assigned' && c.Case_Assigned_Date_Time__c == null) {
c.Case_Assigned_Date_Time__c = System.now();
}
}
}
}

Note:


Make sure that Case_Assigned_Date_Time__c is read only on the page layout.

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to restrict users to update closed Opportunity?
Sample Trigger:

trigger OpportunityTrigger on Opportunity (before update) {
for(Opportunity oppty : trigger.new) {
if(trigger.oldMap.get(oppty.Id).StageName == 'Closed Won') {
oppty.addError('Closed Opportunity cannot be updated');
}
}
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to restrict attachment Size restriction in Salesforce
Sample Trigger:

trigger AttachmentBIUTrigger on Attachment (before insert, before update) {
 for(Attachment att : trigger.new) {
  if(att.Body.size() > 3145728) {
   att.addError('Size cannot be greater than 3 MB');
  }
 }
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to create an attachment and attach it along with the record in Salesforce
Sample Trigger:

trigger sendEmail on Employee__c (after insert) {
List<Attachment> listAttachments = new List<Attachment>();
for(Employee__c e : trigger.new) {
Attachment a = new Attachment();
a.ParentId = e.Id;
a.Name = e.Name + Date.Today();
a.ContentType = 'text/plain';
a.Body = Blob.valueOf(e.Name + ' is added successfully');
listAttachments.add(a);
}
insert listAttachments;
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to add attachments of Lead to Account while we convert the Lead in Salesforce?
Sample Trigger:

trigger LeadTrigger on Lead (after update) {
List<Attachment> listAttachments = new List<Attachment>();
List<Attachment> listInsertAttachments = new List<Attachment>();
set<Id> leadIds = new set<Id>();

for(Lead l : trigger.new) {
if(l.isConverted) {
leadIds.add(l.Id);
}
}

if(leadIds.size() > 0) {
listAttachments = [SELECT Name, Body, ParentId FROM Attachment WHERE ParentId IN: leadIds];

if(listAttachments.size() > 0) {
for(Attachment a : listAttachments ) {
Attachment newAttachment = a.clone();
newAttachment.ParentId = trigger.newMap.get(a.ParentId).ConvertedAccountId;
listInsertAttachments.add(newAttachment);
}

insert listInsertAttachments;
}
}
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to count number of child records in lookup relationship in Salesforce?
Sample Trigger:

trigger HobbyTrigger on Hobby__c (after insert, after delete) {
map<Id, Integer> mapEmpIdHobbyCount = new map<Id, Integer>();
if(trigger.isInsert) {
for(Hobby__c hob : trigger.new) {
if(hob.Employee__c != null) {
if(!mapEmpIdHobbyCount.containsKey(hob.Employee__c)) {
mapEmpIdHobbyCount.put(hob.Employee__c, 1);
} else {
mapEmpIdHobbyCount.put(hob.Employee__c, mapEmpIdHobbyCount.get(hob.Employee__c) + 1);
}
}
}
} else {
for(Hobby__c hob : trigger.old) {
if(hob.Employee__c != null) {
if(!mapEmpIdHobbyCount.containsKey(hob.Employee__c)) {
mapEmpIdHobbyCount.put(hob.Employee__c, -1);
} else {
mapEmpIdHobbyCount.put(hob.Employee__c, mapEmpIdHobbyCount.get(hob.Employee__c) - 1);
}
}
}
}

if(mapEmpIdHobbyCount.size() > 0) {
List<Employee__c> listEmp = [SELECT Id, Number_of_Hobbies__c FROM Employee__c WHERE Id IN : mapEmpIdHobbyCount.keySet()];

for(Employee__c emp : listEmp) {
emp.Number_of_Hobbies__c += mapEmpIdHobbyCount.get(emp.Id);
}

update listEmp;
}
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
Task Trigger
http://3.bp.blogspot.com/-ZpACStXbB3Q/VDNdZRvk_pI/AAAAAAAAFUA/1waHmupgCaE/s1600/task%2Btriggers.png

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to store case's previous status in Salesforce
Sample Trigger:

trigger Case_BU on Case (before update) {
for(Case cas : trigger.new) {
if(cas.Status != trigger.oldMap.get(cas.Id).Status) {
cas.Previous_Case_Status__c = trigger.oldMap.get(cas.Id).Status;
}
}
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to find duplicate case by subject and closing it automatically with existing case comments
Apex Class:

public class CommonVariables {
    public Static Boolean caseRepeatCheck = true;
}

Sample Trigger:

trigger CaseTrigger on Case (after insert) {
if(CommonVariables.caseRepeatCheck) {
CommonVariables.caseRepeatCheck = false;
Set<String> caseSubs = new Set<String>();
Set<Id> caseIds = new Set<Id>();
List<Case> listCases = new List<Case>();
List<Case> listUpdateCases = new List<Case>();
List<CaseComment> listCaseComm = new List<CaseComment>();
List<CaseComment> listInsertCaseComm = new List<CaseComment>();
Map<String, Id> mapCasSubId = new Map<String, Id>();
Map<Id, CaseComment> mapCaseIdCasComm = new Map<Id, CaseComment>();

for(Case cas : trigger.new) {
caseSubs.add(cas.Subject);
caseIds.add(cas.Id);
}

listCases = [SELECT Id, Subject, Description FROM Case WHERE Subject IN : caseSubs AND Id NOT IN : caseIds AND Status = 'Closed'];

if(listCases.size() > 0) {
caseIds = new Set<Id>();
for(Case cas : listCases) {
mapCasSubId.put(cas.Subject, cas.Id);
caseIds.add(cas.Id);
}

listCaseComm = [SELECT Id, CommentBody, ParentId FROM CaseComment WHERE ParentId IN : caseIds];

for(CaseComment casComm : listCaseComm) {
mapCaseIdCasComm.put(casComm.ParentId, casComm);
}

for(Case cas : trigger.new) {
if(mapCasSubId.containsKey(cas.Subject)) {
listUpdateCases.add(new Case(Id = cas.Id, Status = 'Closed'));
listInsertCaseComm.add(new CaseComment(ParentId = cas.Id, CommentBody = mapCaseIdCasComm.get(mapCasSubId.get(cas.Subject)).CommentBody));
}
}

if(listUpdateCases.size() > 0) {
update listUpdateCases;
}

if(listInsertCaseComm.size() > 0) {
insert listInsertCaseComm;
}
}
}
}
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
Merge trigger example in Salesforce
When merge event occurs, in the deleted records, MasterRecordId field will be populated with the winning record id. The winning record will be updated with the values selected.

In the below trigger, when accounts are merged, then deleted record's Name and Website will be stored in Account Backup custom object.

Sample Trigger:

trigger AccountMergeTrigger on Account (after delete) {
List<Account_Backup__c> listAccountBackup = new List<Account_Backup__c>();
for(Account acct : trigger.old) {
if(String.isNotBlank(acct.MasterRecordId)) {
listAccountBackup.add(new Account_Backup__c(Name = acct.Name, Website__c = acct.Website));
}
}
if(listAccountBackup.size() > 0) {
insert listAccountBackup;
}
}

Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
How to update child records when parent record is updated in Salesforce?
Sample trigger:

trigger ContactUpdate on Account (after update) {
set<Id> acctIds = new set<Id>();
map<Id, Account> mapAccount = new map<Id, Account>();
list<Contact> listContact = new list<Contact>();

for(Account acct : trigger.new) {
acctIds.add(acct.Id);
mapAccount.put(acct.Id, acct);
}

listContact = [SELECT MailingStreet, MailingCity, AccountId FROM Contact WHERE AccountId IN : acctIds];

if(listContact.size() > 0) {
for(Contact con : listContact) {
con.MailingStreet = mapAccount.get(con.AccountId).BillingStreet;
con.MailingCity = mapAccount.get(con.AccountId).BillingCity;
}
update listContact;
}
}


Cheers!!!
Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
1 comment:
http://img1.blogblog.com/img/icon18_email.gif
How to create a chatter post using trigger in Salesforce?
Sample Code:

trigger PostFeed on Opportunity(after insert, after update) {
List<FeedItem> FIList = new List<FeedItem>();
Map<Id, Opportunity> oldMap = trigger.oldMap;
for(Opportunity oppty: trigger.new) {
FeedItem FI = new FeedItem();
if(trigger.isInsert && oppty.StageName == 'Closed Won') {
FI.Body = 'Opportunity is closed successfully on ' + system.today() + ' by ' + UserInfo.getName();
} else if(trigger.isUpdate) {
Opportunity tempOppty = oldMap.get(oppty.Id);
if(tempOppty.StageName != oppty.StageName && oppty.StageName == 'Closed Won') {
FI.Body = 'Opportunity is closed successfully on ' + system.today() + ' by ' + UserInfo.getName();
}
}
FI.ParentId = oppty.Id;
if(String.isNotBlank(FI.Body)){
FIList.add(FI);
}
}
if(FIList.size() > 0) {
insert FIList;
}
}

Output:

http://4.bp.blogspot.com/-4Fs9V3PygME/U9uXec5rQZI/AAAAAAAAEz4/nWNOEGnZm_E/s1600/feeditem.png

Labels: Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to compare old field value with the next field value in Salesforce?
Sample Trigger:

trigger emailCheck on Employee__c (before update)
{
Map<Id,Employee__c> o = new Map<Id,Employee__c>();
o = trigger.oldMap;
for(Employee__c n : trigger.new)
{
Employee__c old = new Employee__c();
old = o.get(n.Id);
if(n.Email__c != old.Email__c)
{
n.Email__c.addError('Email cannot be changed');
}
}
}


Output:

http://4.bp.blogspot.com/-c-3TdnZjBaI/U4WT8tCf5sI/AAAAAAAAEPw/0i05ukDxlvo/s1600/trigger.oldmap.png

Labels: Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
How to avoid Recursive Trigger in Salesforce?
Sample Trigger:

trigger AccountTrigger on Account(after insert, after update){

 AccountHandlerController.perform(trigger.New);
}

Sample Classes:


Class for Trigger Handler:


public class AccountHandlerController{
if(CommonUtility.check){
CommonUtility.check = false;
 public static perform(List<Account> listAccount){
  for(Account acct : listAccount){
   ..................
   ..................
   ..................
  }
  update listAccount;
 }
}
}

Class for storing boolean variable

public class CommonUtility{
public static Boolean check = true;
}

If the Boolean variable is not used inside the class, it will cause infinite loop and we will face "maximum trigger depth exceeded exception" in Salesforce.

Note:
The boolean variable should be set to false first and not at the last.

Cheers!!!
Labels: Apex and Visualforce, Apex Controllers, Exceptions in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to add Opportunity owner in Opportunity team
Sample Trigger:

trigger OpportunityTrigger on Opportunity (after insert) {
List<OpportunityTeamMember> listOpptyTeamMem = new List<OpportunityTeamMember>();

for(Opportunity oppty : trigger.New){
OpportunityTeamMember OTM = new OpportunityTeamMember();
OTM.OpportunityId = oppty.Id;
OTM.TeamMemberRole = 'Sales Rep';
OTM.UserId = oppty.OwnerId;
listOpptyTeamMem.add(OTM);
}

if(listOpptyTeamMem.size() > 0){
insert listOpptyTeamMem;
}
}
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger handler controller in Salesforce
Trigger:

trigger Sample on Employee__c(before insert, before update, after insert, after update){
 if(trigger.isBefore){
  if(trigger.isInsert){
   EmployeeHandlerController.onBeforeInsert(trigger.new);
  } else if(trigger.isUpdate){
   EmployeeHandlerController.onBeforeUpdate(trigger.new, trigger.oldMap);
  }
 } else if(trigger.isAfter){
  if(trigger.isInsert){
   EmployeeHandlerController.onAfterInsert(trigger.new);
  } else if(trigger.isUpdate){
   EmployeeHandlerController.onAfterUpdate(trigger.new, trigger.oldMap);
  }
 }
}


Apex Controller:

public class EmployeeHandlerController{

 public static void onBeforeInsert(List<Employee__c> empList){
  /*
  Instead of coding the logic here, call a method by passing empList
  */
 }

 public static void onBeforeUpdate(List<Employee__c> empList, Map<Id, Employee__c> mapEmplOld){
  /*
  Instead of coding the logic here, call a method by passing empList and mapEmplOld
  */
 }

 public static void onAfterInsert(List<Employee__c> empList){
  /*
  Instead of coding the logic here, call a method by passing empList
  */
 }

 public static void onAfterUpdate(List<Employee__c> empList, Map<Id, Employee__c> mapEmplOld){
  /*
  Instead of coding the logic here, call a method by passing empList and mapEmplOld
  */
 }
}
Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
With sharing doesn't work with triggers
Sample Code:

Trigger:


trigger sample on Account (after insert, after update) {
    Sample1.test(trigger.new);
}


Controller:

public with sharing class Sample1{
    public static void test(List<Account> acctList){
        List<Employee__c> empList = new List<Employee__c>();
        for(Account a : acctList){
            Employee__c e = new Employee__c(Name = 'Testing');
            empList.add(e);       
        }     
        insert empList;
    }
}


If an user with no access to Employee object creates an account or updates an account, Employee record with the name, "Testing" will be created with created by name as him/her.


With Sharing doesn't work with triggers.


Cheers!!!


Labels: Apex and Visualforce, Apex Controllers, Customization with code in Salesforce, Information Technology, Salesforce.com, Triggers in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif
Trigger to sum all the child record field and storing it in another object field in Salesforce

Consider the below Scenario
Quote and Structure__c --> Master Detail relationship
Quote and Bigmachine__c --> Lookup relationship
Structure__c and Bigmachine__c --> Lookup relationship

We have to calculate total scope on Big Machine object, which should be the sum of all scope in Structure__c object.


Sample Trigger:


trigger Structure_AIUD on Structure__c (after insert, after update) {
Set<Id> quoteIds = new Set<Id>();
List<Structure__c> structList = new List<Structure__c>();
Map<Id, List<Structure__c>> quoteIdStructListMap = new Map<Id, List<Structure__c>>();
List<Big_Machine__c> bigMachineList = new List<Big_Machine__c>();
Map<Id, Double> quoteIdTotalScopeMap = new Map<Id, Double>();

for(Structure__c struct : trigger.New) {
quoteIds.add(struct.Quote__c);
}

structList = [SELECT Id, Scope__c, Quote__c FROM Structure__c WHERE Quote__C IN : quoteIds];
bigMachineList = [SELECT Id, Total_Scope__c, Quote__c FROM Big_Machine__c WHERE Quote__C IN : quoteIds];

if(bigMachineList.size() > 0) {
if(structList.size() > 0) {
for(Structure__c struct : structList) {
if(!quoteIdStructListMap.containsKey(struct.Quote__c)) {
quoteIdStructListMap.put(struct.Quote__c, new List<Structure__c>());
}
quoteIdStructListMap.get(struct.Quote__c).add(struct);
}

for(Id quoteId : quoteIdStructListMap.keySet()) {
List<Structure__c> tempStructList = new List<Structure__c>();
tempStructList = quoteIdStructListMap.get(quoteId);
Double tempTotalScope = 0;
for(Structure__c struct : tempStructList) {
tempTotalScope = tempTotalScope + struct.Scope__c;
}
quoteIdTotalScopeMap.put(quoteId, tempTotalScope);
}
}
for(Big_Machine__c bigMachine : bigMachineList) {
bigMachine.Total_Scope__c = quoteIdTotalScopeMap.get(bigMachine.Quote__c);
}
update bigMachineList;
}
}

What is the minimum and maximum size for Batch Apex in Salesforce?

Minimum size for Batch Apex in Salesforce is 1.

Maximum size for Batch Apex in Salesforce is 2000.

To know more about Batch Apex in Salesforce, check the below link

http://www.infallibletechie.com/2012/05/batch-apex.html


Note:
1. Default is 200.

2. If you specify the batch size more than 2000, it will consider as 2000.

Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to find number of pending batch jobs in Salesforce?

Sample Code:

List<String> batchStatuses = new List<String> {'Holding', 'Queued', 'Preparing', 'Processing'};
List<AsyncApexJob> listPendingJobs = [SELECT Id FROM AsyncApexJob WHERE Status IN: batchStatuses];

listPendingJobs.size() gives the number of pending batch jobs in Salesforce

Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Simple Batch class for Birthday Notification

Sample Batch class:

global class BirthdayNotificationBatch Implements Database.Batchable <sObject> {
global Database.queryLocator start(Database.BatchableContext bc) {
Date tody = system.today();
String SOQL = 'SELECT Id, Name, Email__c FROM Employee__c WHERE DAY_IN_MONTH(Date_of_Birth__c) = ' +
tody.day() + ' AND CALENDAR_MONTH(Date_of_Birth__c) = ' + tody.month();
return Database.getQueryLocator(SOQL);
}

global void execute(Database.BatchableContext bc, List<Employee__c> listEmployee) {

List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
for(Employee__c m : listEmployee) {
List<String> toAddresses = new List<String>{m.Email__c};
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setToAddresses(toAddresses);
mail.setSubject('Happy Birthday');
String messageBody = '<html><body>Hi ' + m.Name + ',<br/>Happy Birthday.<br/>Many More Happy '+
'Returns of the day.<br/><br/><b>Regards,</b><br/>Admin</body></html>';
mail.setHtmlBody(messageBody);
mailList.add(mail);
}
Messaging.sendEmail(mailList);
}

global void finish(Database.BatchableContext bc) {

}
}

Output:
http://1.bp.blogspot.com/-Y83IJ6KmxvU/VMoHRbK3W6I/AAAAAAAAGAw/z5f2iinm9AE/s1600/Birthday%2Bemail%2Bnotification%2Bin%2Bsalesforce.png

Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to delete the records in sobject that are 3 days old records in Salesforce?

Sample Batch:

global class OldRecordDeleteBatch implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext bc) {
Date threeDaysBefore = System.today().addDays(-3);
String SOQL = 'SELECT Id FROM Employee__c WHERE CreatedDate = : threeDaysBefore';
return Database.getQueryLocator(SOQL);
}

global void execute(Database.BatchableContext bc, List <Employee__c> listEmp) {
delete listEmp;
}

global void finish(Database.BatchableContext bc) {
}
}


Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to maintain variable value inside the Batch class?

To maintain variable value inside the Batch class, Database.Stateful is used.

Sample Class:


global class Class_Name implements Database.Batchable<sobject>, Database.Stateful{
Integer i = 0;
global Database.QueryLocator start(Database.BatchableContext bc){
return Database.getQueryLocatory('SELECT Id, Name, Sequence_Number__c FROM Employee__c');
}

global void execute(Database.BatchableContext bc, List<Employee__c> listEmployee){
for(Employee__c e : listEmp){
e.Sequence_Number__c = i;
i += 1;
}
}

global void finish(Database.BatchableContext bc){
}
}

here i value will be maintained even though execute method is called several times.

Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Batch Apex Syntax

Syntax:

global class class_Name Implements Database.Batchable <sObject> {
global Database.queryLocator start(Database.BatchableContext bc) {
String SOQL = 'SELECT Id FROM sObject';
return Database.getQueryLocator(SOQL);
}

global void execute(Database.BatchableContext bc, List<sObject> scope) {

}

global void finish(Database.BatchableContext bc) {

}
}

To execute:

Class_Name obj = new Class_Name();
Database.executeBatch(obj);

To schedule:

global class Scheduleclass_Name Implements Schedulable {
global void execute(SchedulableContext sc) {
Class_Name obj = new Class_Name();
Database.executeBatch(obj);
}
}

Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

System.schedule in Apex scheduler in Salsforce

Sample code:

SampleSchedulableClass obj = new SampleSchedulableClass();

String cron = '0 59 * * * *'

System.schedule('Testing', cron, obj);

The above code executes SampleSchedulableClass for every one hour.

Syntax for Cron:

Seconds Minutes Hours Day Month Week Year

Seconds : 0 - 59
Minutes : 0 - 59
Hours : 0 - 23
Day : 1 - 31
Month : 1 - 12
Week : 1 - 7(Sunday is first and Saturday is last)
Year : upto 2099

Year is optional.
Expression
Description
0 0 13 * * ?
Class runs every day at 1 PM.
0 0 22 ? * 6L
Class runs the last Friday of every month at 10 PM.
0 0 10 ? * MON-FRI
Class runs Monday through Friday at 10 AM.
0 0 20 * * ? 2010
Class runs every day at 8 PM during the year 2010.

? - No value
* - All values
L - Last
W - Nearest weekday

Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
6 comments:
http://img1.blogblog.com/img/icon18_email.gif

How to schedule Batch Class for every hour in Salesforce?

Sample code:

SampleSchedulableClass obj = new SampleSchedulableClass();

String cron = '0 59 * * * *'

System.schedule('Testing', cron, obj);

Expression
Description
0 0 13 * * ?
Class runs every day at 1 PM.
0 0 22 ? * 6L
Class runs the last Friday of every month at 10 PM.
0 0 10 ? * MON-FRI
Class runs Monday through Friday at 10 AM.
0 0 20 * * ? 2010
Class runs every day at 8 PM during the year 2010.


Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
1 comment:
http://img1.blogblog.com/img/icon18_email.gif

How to escalate cases using Apex in Salesforce?

Sample Code:

Batch Class:


global class CaseEscalation implements Database.Batchable <sObject>{

global Database.QueryLocator start(Database.BatchableContext bc){
String SOQL = 'SELECT Id, IsEscalated FROM Case WHERE Status = \'High\' AND IsEscalated = False';
return Database.getQueryLocator(SOQL);
}

global void execute(Database.BatchableContext bc, List<Case> caseList){
for(Case c : caseList){
c.IsEscalated = true;
}
update caseList;
}

global void finish(Database.BatchableContext bc){
}
}

Schedulable Class:

global class CaseEscalationSchedule implements Schedulable{
global void execute(SchedulableContext sc){
CaseEscalation ce = new CaseEscalation();
Database.executeBatch(ce);
}
}
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to avoid concurrent batch execution in Salesforce?

Sample Code:

if ([SELECT count() FROM AsyncApexJob WHERE JobType='BatchApex' AND (Status = 'Processing' OR Status = 'Preparing')] < 1]){
Database.executeBatch(batchClassInstance);
} else {
Schedulable_Class sc = new Schedulable_Class();
Datetime dat = Datetime.now().addMinutes(30); // This is for 30 mins delay
String timeForScheduler = dat.format('s m H d M \'?\' yyyy');
Id scheduleId = System.Schedule('Trying again' + timeForScheduler, timeForScheduler,sc);
}


Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to get batch status using Apex code?

Sample Code:

public String status {get;set;}

Id batchId;

/*Method to call the batch class*/
public void startBatch(){
batchAccountUpdate obj = new batchAccountUpdate();
batchid = Database.executebatch(obj);
}

/*Method to check the status of batch*/
public void checkStatus(){
AsyncApexJob aaj = [SELECT Status FROM AsyncApexJob WHERE ID =: batchId];

status = aaj.Status;
}


Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to check whether my Batch Apex or Future Method or Scheduled Apex completed in Salesforce?

Go to Set up --> Jobs --> Apex Jobs to check whether my Batch Apex or Future Method or Scheduled Apex completed.

http://4.bp.blogspot.com/-xNXMzHftTxc/UrPOvgSOjtI/AAAAAAAADfE/ewo3VCQm8A8/s1600/apex+jobs.png


Cheers!!!
Batch Apex in SalesforceInformation TechnologyPoint and click configuration in SalesforceSalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Test class for Batch Apex in Salesforce

When testing your batch Apex, you can test only one execution of the execute method. You can use the scope parameter of the executeBatch method to limit the number of records passed into the execute method to ensure that you aren't running into governor limits.

The executeBatch method starts an asynchronous process. This means that when you test batch Apex, you must make certain that the batch job is finished before testing against the results. Use the Test methods startTest and stopTest around the executeBatch method to ensure it finishes before continuing your test. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously. If you don’t include the executeBatch method within the startTest and stopTest methods, the batch job executes at the end of your test method for Apex saved using Salesforce.com API version 25.0 and later, but not in earlier versions.

Starting with Apex saved using Salesforce.com API version 22.0, exceptions that occur during the execution of a batch Apex job that is invoked by a test method are now passed to the calling test method, and as a result, causes the test method to fail. If you want to handle exceptions in the test method, enclose the code in try and catch statements. You must place the catch block after the stopTest method. Note however that with Apex saved using Salesforce.com API version 21.0 and earlier, such exceptions don't get passed to the test method and don't cause test methods to fail.

Sample Test Class:

@isTest
public class SampleTest {
public static testMethod void testBatch() {
Test.StartTest();
Batch_Class_Name obj = new Batch_Class_Name();
ID batchprocessid = Database.executeBatch(obj );
Test.StopTest();
}
}


Cheers!!!
Batch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.comUnit testing in Salesforce
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Apex Scheduler Limits

Sa1lesforce.com has set some limits on Apex Scheduler. Below are the limits in Apex Scheduler in Salesforce.com.

1. You can only have
100 scheduled Apex jobs at one time(Maximum number of Apex classes scheduled concurrently).

2. The maximum number of scheduled Apex executions per a
24-hour period is 250,000 or the number of user licenses in your organization multiplied by 200, whichever is greater. The licenses that count toward this limit are full Salesforce user licenses or Force.com App Subscription user licenses. Chatter Free, Chatter customer users, Customer Portal User, and partner portal User licenses aren't included.


Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Difference between Database.query() and Database.getQueryLocator


Database.query()
Database.getQueryLocator
We can retrieve up to 50,000 records.
We can retrieve up to 10,000 records.
If VF page doesn’t have read only attribute, use Database.query().
If VF page have read only attribute, use Database.getQueryLocator().
In Batch Apex, if we use Database.query(), it supports 50,000 records only.
In Batch Apex, if we use Database.getQueryLocator(), it supports upto 50 million records.


Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

What is the difference between Database.QueryLocator and Iterable in Batch Apex in Salesforce.?

Database.QueryLocator:

50 Million records can be returned.

Iterable<sObject>:

Governor limits will be enforced. So, we can use upto 50,000 records only. Else, exception will be thrown.
You can also use the iterable to create your own custom process for iterating through the list.


Cheers!!!
Batch Apex in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

How to limit number of records to be processed per transaction in Batch Apex?

The Database.executeBatch method takes an optional parameter scope. This parameter specifies the number of records that should be passed into the execute method.

Syntax:

Database.executeBatch(instance of batch class,scope);

Sample:

AccountUpdate au = new AccountUpdate();
Database.executeBatch(au,1500);

The limit for scope parameter is
2000.

The default value is
200.

If the scope value is greater than 2000, it will consider as 2000 and then process.


Cheers!!!
Batch Apex in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Expiry notification through email using schedulable class in Salesforce

Sample Code:

Batch Apex Class:

global class expireNotify implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext bc) {
Date d = Date.today();
String soql = 'SELECT Expiry_Date__c, Name, Email_Address__c FROM Member__c WHERE Expiry_Date__c =: d';
return Database.getQueryLocator(soql);
}

global void execute(Database.BatchableContext bc, List<Member__c> recs) {
List<Messaging.SingleEmailMessage> mailList = new List<Messaging.SingleEmailMessage>();
for(Member__c m : recs) {
List<String> toAddresses = new List<String>();
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
toAddresses.add(m.Email_Address__c);
mail.setToAddresses(toAddresses);
mail.setSubject('Welcome to Sweet 16 Siebel Batch');
String messageBody = '<html><body>Hi ' + m.Name + ',<br>Your account Expires today. <br>Kindly contact your administrator.<br><br><b>Regards,</b><br>Magulan D</body></html>';
mail.setHtmlBody(messageBody);
mailList.add(mail);
}
Messaging.sendEmail(mailList);
}

global void finish(Database.BatchableContext bc) {
}
}


Schedulable Class:

global class scheduleExpireNotify implements Schedulable {
global void execute(SchedulableContext sc) {
expireNotify en = new expireNotify();

Database.executeBatch(en);
}
}

Schedule the 'scheduleExpireNotify' as mentioned below in App Setup --> Apex Classes --> Schedule Apex and select 'sscheduleExpireNotify' class. Check Weekly and select all the days. Give Start and End dates and Preferred Start time and Click 'Save' button.
http://2.bp.blogspot.com/-g3gek-O1K9w/UR3yW0WjaLI/AAAAAAAABao/Xow3q7TIfOw/s640/schedule+class.png

http://4.bp.blogspot.com/-P4BbqBvukhY/UR3y5UUqRaI/AAAAAAAABaw/H0fZSO1Rdp0/s1600/apex+jobs.png
Batch Apex in SalesforceInformation TechnologySalesforce.com
No comments:
http://img1.blogblog.com/img/icon18_email.gif

Simple Batch Apex example in Salesforce

Apex Code:

global class batchAccountUpdate implements Database.Batchable<sObject> {
global Database.QueryLocator start(Database.BatchableContext BC) {
String query = 'SELECT Id,Name FROM Account';
return Database.getQueryLocator(query);
}

global void execute(Database.BatchableContext BC, List<Account> scope) {
for(Account a : scope)
{
a.Name = a.Name + 'Updated';
}
update scope;
}

global void finish(Database.BatchableContext BC) {
}
}

Run the batch apex for testing it in Developer Console
.
http://1.bp.blogspot.com/-MwHUUR7Pkbw/UQKifIxmtDI/AAAAAAAAA9s/n8hKaqTiPvk/s640/executing+batch+apex.png

Output:
http://1.bp.blogspot.com/-JNf5W5UWq3U/UQKjZyQJhZI/AAAAAAAAA94/FCU72R69ttc/s1600/batch+apex.png

Cheers!!!
Apex and VisualforceApex ControllersBatch Apex in SalesforceCustomization with code in SalesforceInformation TechnologySalesforce.com
13 comments:
http://img1.blogblog.com/img/icon18_email.gif

Birthday Reminder or Automatic Birthday wisher using apex in Saleforce

For Birthday Reminder or Automatic Birthday wisher using apex in Saleforce, use the below codes. I have implemented this using Batch Apex.

MemberIterable:

global class MemberIterable implements Iterator<Member__c>{
List<Member__c> memList{get; set;}
Integer i {get; set;}

public MemberIterable() {
memList = [SELECT E_Mail_Id__c,
Birthday__cFROM Member__c];
i = 0;
}
global boolean hasNext() {
if(i >= memList.size())
{
return false;
} else {
return true;
}
}


globalMember__cnext() {
if(i > memList.size()) {
return null;
}
i++;
return memList[i-1];
}
}

callMemberIterable:

global class callMemberIterable implements iterable<Member__c> {
global Iterator<
Member__c> Iterator() {
return new memberIterable();
}
}

memberBirthdayBatch:

global class memberBirthdayBatch implements Database.batchable<Member__c> {
global Iterable<
Member__c> start(Database.batchableContext info) {
System.debug('Start method');
return new callMemberIterable();
}
global void execute(Database.batchableContext info, List<
Member__c> scope) {
List<
Member__c> memsToUpdate = new List<Member__c>();
System.debug('Member list size is ' + scope.size());
for(
Member__cm : scope) {
Date myDate = date.today();
Integer todayDy = myDate.day();
Integer todayMon = myDate.month();
System.debug('Day is ' + m.
Birthday__c.day());
Integer dy = m.
Birthday__c.day();
Integer mon = m.Birthday__c.month();
if(todayDy == dy && todayMon == mon) {
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<String> toAddresses = new List<String>();
toAddresses.add(m.E_Mail_Id__c);
email.setToAddresses(toAddresses);
List<String> ccAddresses = new List<String>();
ccAddresses.add('magulancse24@gmail.com');
email.setCcAddresses(ccAddresses);
email.setSubject('Happy Birthday. Have a blast -- Birthday Reminder!');
String message = '<html><table cellspacing = "7"><tr><td style="font-weight:bold;color:green;">Happy Birthday!!!</td></tr><tr><td style="font-weight:bold;color:pink;">Many more Happy returns of the day.</td></tr><tr><td></td></tr><tr><td></td></tr><tr><td style="font-weight:bold;">Cheers,</td></tr><tr><td style="font-weight:bold;">Magulan D</td></tr></table></html>';
email.setHtmlBody(message);
Messaging.sendEmail(new Messaging.SingleEmailMessage[]{email});
}
}
}
global void finish(Database.batchableContext info) {
}
}


scheduleBirthdayWish:

global class scheduleBirthdayWish implements Schedulable {
global void execute(SchedulableContext SC) {
memberBirthdayBatch mbw = new memberBirthdayBatch();

Database.executeBatch(mbw);
}
}

Schedule the 'scheduleBirthdayWish' as mentioned below in App Setup --> Apex Classes --> Schedule Apex and select 'scheduleBirthdayWish' class. Check Weekly and select all the days. Give Start and End dates and Preferred Start time and Click 'Save' button.
http://1.bp.blogspot.com/-0z6pDLActyg/UGBPio8cC1I/AAAAAAAAAe8/UV9gQyJxf_4/s640/Birthday+Reminder.png

http://2.bp.blogspot.com/-sZ--F_-NOy0/UGBQThKmCiI/AAAAAAAAAfE/L0CaO-r7kCs/s640/Birthday+Reminder.png

To check the scheduled job, go to Administration Setup --> Monitoring --> Scheduled Jobs
http://4.bp.blogspot.com/-H9veTXpnX38/UGBQ7kuII1I/AAAAAAAAAfM/1KKrTuxDLqo/s640/Birthday+Reminder.png

Batch Apex in Salesforce
A developer can now employ batch Apex to build complex, long-running processes that run on thousands of records on the Force.com platform. Batch Apex operates over small batches of records, covering your entire record set and breaking the processing down to manageable chunks. For example, a developer could build an archiving solution that runs on a nightly basis, looking for records past a certain date and adding them to an archive. Or a developer could build a data cleansing operation that goes through all Accounts and Opportunities on a nightly basis and updates them if necessary, based on custom criteria.

Batch Apex is exposed as an interface that must be implemented by the developer. Batch jobs can be programmatically invoked at runtime using Apex.
To use batch Apex, you must write an Apex class that implements the Salesforce-provided interface Database.Batchable, and then invoke the class programmatically.

To monitor or stop the execution of the batch Apex job, go to Setup -->Monitoring--> Apex Jobs. For more information, see “Monitoring the Apex Job Queue” in the Salesforce online help.

The Database.Batchable interface contains three methods that must be implemented:
start method
global (Database.QueryLocator | Iterable<sObject>) start(Database.BatchableContext bc) {}
The start method is called at the beginning of a batch Apex job. Use the start method to collect the records or objects to be passed to the interface method execute. This method returns either a Database.QueryLocator object or an iterable that contains the records or objects being passed into the job.
execute method
global void execute(Database.BatchableContext BC, list<P>){}
The execute method is called for each batch of records passed to the method. Use this method to do all required processing for each chunk of data.

This method takes the following:
oA reference to the Database.BatchableContext object.
oA list of sObjects, such as List<sObject>, or a list of parameterized types. If you are using a Database.QueryLocator, the returned list should be used.
Batches of records are not guaranteed to execute in the order they are received from the start method.
finish method
global void finish(Database.BatchableContext BC){}


The finish method is called after all batches are processed. Use this method to send confirmation emails or execute post-processing operations.
Batch Apex Governor Limits
Keep in mind the following governor limits for batch Apex:
  • Up to five queued or active batch jobs are allowed for Apex.
  • A user can have up to five query cursors open at a time. For example, if five cursors are open and a client application still logged in as the same user attempts to open a new one, the oldest of the five cursors is released.
  • Cursor limits for different Force.com features are tracked separately. For example, you can have five Apex query cursors, five batch cursors, and five Visualforce cursors open at the same time.
  • A maximum of 50 million records can be returned in the Database.QueryLocator object. If more than 50 million records are returned, the batch job is immediately terminated and marked as Failed.
  • The maximum value for the optional scope parameter is 2,000. If set to a higher value, Salesforce chunks the records returned by the QueryLocator into smaller batches of up to 2,000 records.
  • If no size is specified with the optional scope parameter, Salesforce chunks the records returned by the QueryLocator into batches of 200, and then passes each batch to the execute method. Apex governor limits are reset for each execution of execute.
  • The start, execute and finish methods can implement only one callout in each method.
  • Batch executions are limited to one callout per execution.
  • The maximum number of batch executions is 250,000 per 24 hours.
Only one batch Apex job's start method can run at a time in an organization. Batch jobs that haven’t started yet remain in the queue until they're started. Note that this limit doesn’t cause any batch job to fail and execute methods of batch Apex jobs still run in parallel if more than one job is running.

Step 1: Write an apex class for Batch Apex.

Sample code:

global class AccountUpdate implements Database.batchable<sObject>
{

String query,field,value;
global AccountUpdate(String f, String v)
{
field = f;
value = v;
query = 'Select ' + field + ' FROM Account';
}

global Database.QueryLocator start(Database.BatchableContext BC)
{
return Database.getQueryLocator(query);
}
global void execute(Database.BatchableContext BC, List<sObject> scope)
{
for(sobject s : scope)
{
s.put(Field,Value);
}
update scope;
}
global void finish(Database.BatchableContext BC)
{
}
}

            The above class is used to update Description field with some value.

Step 2: Go to Setup à Developer Console.

http://1.bp.blogspot.com/-1RkYIAjnGJY/T7oHE-kilEI/AAAAAAAAAQc/s4dpVXmcuwE/s1600/Batch+Apex.JPG

Step 3: Execute the Batch Apex.

http://3.bp.blogspot.com/-_TQSIr2ZQLE/T7oHMjDRP5I/AAAAAAAAAQk/DbyL_TMjJg4/s640/Batch+Apex.JPG


Step 4:Monitor the Apex jobs.
To monitor the Apex jobs, go to Setup --> Monitoring --> Apex Jobs.

http://4.bp.blogspot.com/-wmN9Zx8I-Mc/T7oHZnU47dI/AAAAAAAAAQs/Sl6vayhUiys/s1600/Batch+Apex.JPG

http://2.bp.blogspot.com/-A_2w3PLNyFs/T7oHkCleclI/AAAAAAAAAQ0/WTJGqbpfRyo/s640/Batch+Apex.JPG



No comments: