Confirm Dialog box in Visualforce page

Visualforce Page:

            <apex:pageblocksection title="Confirm dialog box Demo" collapsible="false">
                 <apex:commandbutton value="Click to Confirm" onclick="return confirm('Do you want to submit');"></apex:commandbutton>


Hide Current Date Link For Date Type Inputfield

The standard apex:inputfield component for a date field generates current date link next to the input field. Sometimes we need to hide this link.

Here is an example to hide the current date link for date type inputfield. Here I’ve added the visibility:hidden in dateFormat CSS class to hide the link.

<style type="text/css">

Visualforce Page:

<apex:page standardController="Opportunity"> 
    <style type="text/css">
        <apex:pageBlock title="Opportunity">  
            <apex:pageBlockSection title="Opportunity Information">  
                <apex:inputField value="{!Opportunity.Name}"/> 
                <apex:inputField value="{!Opportunity.Amount}"/>  
                <apex:inputField value="{!Opportunity.Type}"/> 
                <apex:inputField value="{!Opportunity.LeadSource}"/> 
                <apex:inputField value="{!Opportunity.CloseDate}"/>  


Converting DateTime to format YYYY-MM-DDThh:mm:ssZ in Salesforce


It can be used in SOQL query. SOSL query returns the datetime in format(YYYY-MM-DDThh:mm:ssZ) so for comparison we need to convert it into above format.

Calculate Age from Date of Birth using Apex in Salesforce

Apex Class:

public class CalculateAge
    public Integer age {get; set;}    
    public Date dt {get; set;}
    public void FindAge()
        Integer days = dt.daysBetween(Date.Today());
        age = Integer.valueOf(days/365);

Visualforce Page:

<apex:page doctype="html-5.0" controller="CalculateAge">
        <apex:pageblock title="Calculate Age From Date of Birth">
                <apex:pageblocksectionitem>Date of Birth:
                    <apex:inputtext onfocus="DatePicker.pickDate(true, this , false);" value="{!dt}"></apex:inputtext></apex:pageblocksectionitem>
                    <apex:commandbutton value="Get Age" action="{!FindAge}"></apex:commandbutton>
                    <apex:outputtext value="{!age}"></apex:outputtext>



Process Builder in Salesforce

The Process Builder is a workflow tool that helps to easily automate the business processes by providing a powerful and user-friendly visual representation of the process as we build it. The Process Builder user interface has several functional areas that we should understand before creating a process.

This feature is available, as Beta, since Winter ’15 (Release Notes) and Generally Available since Spring ’15 (Release Notes). It available in Enterprise, Performance, Unlimited, and Developer Editions.

For example here is a scenario: Automatically create an Opportunity upon the creation of a Account for which Type = “Customer – Direct”
Step 1:
Go to Setup | App Setup | Create | Workflow & Approvals | Process Builder.


Step 2:
Review Process Builder start page and click ‘New” to start building.


Step 3:
Create new process.


Step 4:
Select the object to be evaluated (in this case, Account).


Step 5:
Review current process after object added.


Step 6:
Add criteria that will determine when action(s) will be triggered.


Step 7:
Name the criteria and select when actions should be evaluated.


Step 8:
Create filter condition.


Step 9:
Apply filter value (Type = “Customer – Direct”) and review your filter.


Step 10:
Save filter criteria.


Step 11:
Add a corresponding action.


Step 12:
Fill the action name and the required fields for the new Opportunity record.


Step 13:
Activate the process by clicking on “Activate” at the top right.


Review activated process.


Review all of your processes by navigating to “My Processes”.


Now you can create an account with type value “Customer – Direct”, and check automatically an Opportunity will create.