Thursday 22 December 2011

How to use 'Schema- Builder' in Salesforce


Hi All,  while working with salesforce we have to deal with many S-Object and Custom-Objects.we need to set up relation ship (Master/Lookup) among these all.But to keep this relation-ship in mind is very typical.
 To get a rid of this problem Salesforce has provided it's new tool "Schema-Builder".

Specification:-
--------------
In Schema Builder We may observe relation ship among many objects.Different different color lining are used to make it clear and out of any sort of technical-dilemma.
to configure
1.)go to Set up ->App setup->where you will easily 'Schema builder' link.

2.) click on this link you will be redirected t new Page with schema home page where you will get a list of objects.
3.) Select object to view pre-defined relationship among them.


Saturday 26 November 2011

How to Transfer Attachments from One Sobject to Another One

Here I am giving an example to transfer attachments from Opportunity to case Sobject
 
List insertingAttachments = new List();
List deletingAttachments = new List();
for(Attachment atch :  [select id,name,body from Attachment where parentid = 'your Opportunity id' ]){
   Attachment  newattch = new Attachment();  
   newattch = atch.clone(false);
   newattch.body = atch.body; // required field
  newattch.name = atch.name;// required field  
  newattch .parentId = 'your Case id ';
  insertingAttachments.add(newattch); 
  deletingAttachments.add(atch);
}
insert   insertingAttachments;
delete  deletingAttachments 

Wednesday 12 October 2011

How to use custom DatePicker Using Salesforce Js for all Locales

Hi Friends today I came with a custom datepicker which can be used in visualforce Page.By using this we don't need to use any Jquery or static resource. I faced this problem and got this code from some where Please Click Here
to go to that place. but this DatePicker was only for specific USA locale. I made small changes for using in my Vf page Final VF-code is as follows:-
  



    
    
    




    Date Lookup
    
    
    
    
    
    
    




 {!TODAY()} ]
 
Previous Month Next Month
SunMonTueWedThuFriSat


So I made it useful for those whose user has different Locale also creating it's controller as follows:-
Controller-code:-
  
public class datePickercontroller {
public date converedDate{get;private set;}
public string selectedDate{get;
    set
    {   if(value!=null || value != ''){
            Integer month_num = Integer.valueOf(value.subString(0,value.indexOf('/', 0)));
            Integer date_num = Integer.valueOf(value.subString(value.indexOf('/', 0)+1,value.indexOf('/',value.indexOf('/', 0)+1 ))); 
            Integer year_num = Integer.valueOf(value.subString(value.indexOf('/', 0)+value.indexOf('/',value.indexOf('/', 0)+1 ),value.length()));
            converedDate = date.newinstance(year_num , month_num ,date_num );
        }
    }
}
}
I think this way would be useful for you.
Credit for this DatePicker should goes to it's developer I got this Code form this link click Here
with regards...

Sunday 2 October 2011

How to watch Streets in Google Map

Hi I am again back with something new to know. Google provides street view of USA in 3D format. this Feature make you Feel something like real experience.
Step.1 type http://map.google.com now type any place and click on simply "Get Direction" click on human symbol. You will get snaps like as follows
with regards...

How to use "Voice Search" on Google

Hi Friends..!! Today I am back with sonthing interesting. have you thought how it would be easy to search any thing in Google without writing a single character? Yes Google has launched this feature of voice search. We will understand this feature step by step
Step1. use URL https://encrypted.google.com/
Step2. Click on a symbol of mic in Searching input Text Box.
Step3. when you click on mic symbol you will get a message Box Start to say anything (prefer to speak English Words)
You can go to encrypted Google directly by clicking click Here Now Enjoy this feature.
Thanks Google
with regards...

Saturday 2 July 2011

How to replace ' by \' in a string in Apex


Mostly This problem came in front when You need to use dynamic Query in which you can not use String with single quote so We have to replace ' in to \' 
There are two  Approach as follows :
If your String is InputString = "sj'ase'aa'"
First Approach
===========
Use String Method
string.escapeSingleQuotes(InputString);
output would be sj\'ase\'aa\'
Second Approach:
============

if(InputString.contains('\'')){
                       InputStringInputString.replaceAll('\'', '\\\\\'');
                                   
}

But Second Approach is limited up to only single quote but when you use back slash you can not use this approach.
so go to first one.

Friday 24 June 2011

How to Use ANT in salesforce


Hi friends here We will learn How to deal with deployment process using ANT. If you have ANT then fine
other wise download apache-ant-1.8.2 or higher version and go through these steps for installing ANT.
Step 1 Download apache-ant-1.8.2-bin from Web.
step 2 install jdk1.6.0_25 or higher version.
Step 3 go to run command use command sysdm.cpl press "advanced" tab then press "environment variable" tab then system variable section press on
tab "New"

create two variable ANT_HOME and JAVA_HOME
ANT_HOME D:\apache-ant-1.8.2-bin\apache-ant-1.8.2 (if your ant folder is in D- drive)                  
JAVA_HOME C:\Program Files\Java\jdk1.6.0_25 (give path of jdk)
now check there will be a another variable "PATH" in that you need to append these newly created variable's with bin location value separating with semicolon.

PATH append like this oldpath; C:\ProgramFiles\Java\jdk1.6.0_25\jre\bin;D:\apache-ant-1.8.2-bin\apache-ant-1.8.2\bin;
(if path variable is already a variable then append this also other wise create new Path variable)

Step4: Go to Salesforce - Setup -. Tool-> Force.com migration download it.
Step5: Extract this downloded zip folder and copy ant-salesforce jar file and put it in lib folder in apache folder.

for more detail go to
http://ant.apache.org/manual/index.html

Now we move to "How to Use ANT for deployment in Apex"

for this Process
1) First of all create package.xml(depends requirement )
2) And Use build.xml and
3) build.property (change credential according to your requirement)








Thursday 23 June 2011

Conditional Style and disabled attribute in Apex

I faced a problem that how we can use some attributes like style and disabled on any condition .
Here I want to share the approach that -
1) How to apply style on any condition
2) How to use disabled on any condition
Explanation  is given below with an example (To disable locked Accounts and to change background color for that account )

VF Page code :-
  

    
        
            
                
                    
                    
                           
                       
                
             
           
               
                   
               
       
   


Controller Code:-
  
public with sharing class Styewithcondition {
    public List accList{get;set;}
    //constructor 
    public styewithcondition(){
        accList = [select name,Locked__c from Account where name like 'a%'];
    }
    public void lockAccount(){
        update accList;
    }
    public void UnlockAllAccount(){
       for(Account a:  accList )
       {   if(a.locked__c == true)
           a.locked__c = false;
       }
       update accList;
    }
}

Screen Shot :-
By this code you can lock and unlock Account from a single list.

Tuesday 31 May 2011

Calculating Age From Date of Birth

Recently I got inspired from one of my favorite technical article spot (http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html) for calculating Age of from Date of Birth. Here I have added some flexibility for getting age up to month Level just copy and paste following code in your formula field  (which should be of number type).of years
**********************************************************************************

If(
   OR(
      And(
           MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
     ),
      And(
  MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
         )
      ),
         (YEAR(TODAY())-YEAR(DOB_API)),
         If(
            OR(
               And(
                   MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
                  ),
               And(
                  MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
                  )
              ),
         (YEAR(TODAY())-YEAR(DOB_API )-1),
0
           )
)


**********************************************************************************
and for months copy and paste following code in your formula field (which should be of number type).of months.
**********************************************************************************


If(
   OR(
      And(
           MONTH(TODAY())>=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
      ),
      And(
   MONTH(TODAY())>MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API )
         )
      ),
        MONTH(TODAY())-MONTH(DOB_API) ,
         If(
            OR(
               And(
                   MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())>=DAY(DOB_API)
                  ),
               And(
                  MONTH(TODAY())<=MONTH(DOB_API),DAY(TODAY())<DAY(DOB_API)
                  )
              ),
        (12-MONTH(DOB_API ))+MONTH(TODAY()) ,
0
           )
)

**********************************************************************************
Here You will get Age in years like if your DOB is 5/8/1990 then Today(31/5/2011) then your age would be 20 years 9 months.

I would like to refer great thanks and whole credit to Mr. Ankit Arora dropping focus on this topic.
Source : http://forceguru.blogspot.com/2011/05/calculating-age-from-birth-date.html

Friday 27 May 2011

How to Use Field Set in VF page

Problem :-  We have to show some fields on VF Page and can add/remove fields on page at run time without making any change in VF page code.
Solution :- So here we can go through step by step.
Step1):-
             follow by clicking in sandBox org. on User's Name>Setup>customize>Account(any standard Object)>field set.
Step2.):-
           Create New field Set According to requirement.
(One thing should keep in mind once you create Available list in field Set then after making package you can not change it)
Step3.):-
           Create your VF page(Here I am mentioning one Sample Code)

VF Page code:-



    
       
           
               
                             
       
        
                           
           
    
Screen Shot:-




Here I have included 4 fields of Account Sobject if I want to add/remove some fileds I can easily do this just by changing in field Set (not need to change in VF page).we can use field set for custom object also.




Wednesday 18 May 2011

How to show Accounts List (in Different views ) on DashBoard

Solution :- step1- Create Vf Page(page coding is given below).
  



    
        
        
            
            
            
        
       
    
    
    
        
        {!a.name}
        
    



step 2 go to DashBoard Simply click on DashBoard Tab and then click on List of DashBoards Create or Edit any Dash Board then goto Data sources and select Vf page which you have Created above. step3. Now you are able to look name of Accounts in following views on DashBoard
        A)My Accounts
        B)Accounts are Created/Modified in recent week
        C)Recently viewed Accounts
        D)All Accounts

Wednesday 11 May 2011

Use Date Picker while header & sidebar should not be visible

Problem : when we make showHeader false then We cannot use Date-picker
so we can use following two methods:
1.First approach Use inline=1 in Url(of VF page at run time ) at last
 2. Second Approach Use JavaScript to hide Header and Side Bar without making these false
 Visual Page Code:
  


    

    
     Your Date Birth :